 ('2017Q2', 'MARGIN'): 0.16, ('2017Q2', 'PROFIT'): 3262.6666666666665}, {('2016Q4', 'SALES'): 1237.3083333333332, ('2017Q3', 'PROFIT'): 64.180476190476185, ('2017Q1', 'PROFIT'): 97.9553333333333, ('2017Q2', 'SALES'): 718.68500000000006, ('2017Q3', 'MARGIN'): 0.1219152103415191, ('2016Q4', 'PROFIT'): 88.209999999999994}]

A:

I couldn't get the above solution to work.
So I did this:
df['MARGIN'] = (df['PROFIT'].astype(float) / df['SALES'].astype(float))
df['MARGIN'] = df['MARGIN'].astype(float)
df['PREV_MARGIN'] = df['MARGIN'].shift(-1)
df['VARIANCE'] = df['MARGIN'] - df['PREV_MARGIN']
df = df.drop('PREV_MARGIN', axis=1)

This gets me the data I need to complete my work.  

 Q:

Query with sub-query performs terrible

I'm having a problem with the performance of the following query, I want to get some info about saleslines and per salesline I want to find out the last date is was received in stock:
SELECT        XAL_SUPERVISOR.SALESTABLE.SALESNUMBER, XAL_SUPERVISOR.SALESTABLE.DEBTORACCOUNT, XAL_SUPERVISOR.SALESTABLE.DELIVERYNAME, 
                     XAL_SUPERVISOR.SALESTABLE.DELIVERYADDRESS3, XAL_SUPERVISOR.SALESTABLE.REQUISNUMBER, XAL_SUPERVISOR.SALESTABLE.CUSTOMERREF, 
                     XAL_SUPERVISOR.SALESTABLE.ROUTE, XAL_SUPERVISOR.SALESTABLE.ROUTENUMBER, XAL_SUPERVISOR.SALESTABLE.CMPVWSTATUS, 
                     
(' 2017Q2',' MARGIN' ): 0.16, (' 2017Q2',' PROFIT' ): 3262.6666666666665 }, { (' 2016Q4',' SALES' ): 1237.3083333333332, (' 2017Q3',' PROFIT' ): 64.180476190476185, (' 2017Q1',' PROFIT' ): 97.9553333333333, (' 2017Q2',' SALES' ): 718.68500000000006, (' 2017Q3',' gross profit' ): 0.1219152103415191, (' 2016Q4',' net income' ): 88.209999999999994 } ] 

 A: 

 I couldn't get the above solution to workplace. 
 then I did this: 
 df['MARGIN' ] = (df['PROFIT'].astype(float) / df['SALES'].astype(float) ) 
 df['MARGIN' ] = df['MARGIN'].astype(float) 
 df['PREV_MARGIN' ] = df['MARGIN'].shift(-1) 
 df['VARIANCE' ] = df['MARGIN' ] - df['PREV_MARGIN' ] 
 df = df.drop('PREV_MARGIN', axis=1) 

 This gets me the datum I need to complete my work.  

  Q: 

 Query with sub - question perform terrible 

 I'm suffer a problem with the operation of the following query, I want to get some info about saleslines and per salesline I want to find out the concluding date is was received in stock: 
 SELECT         XAL_SUPERVISOR.SALESTABLE.SALESNUMBER, XAL_SUPERVISOR.SALESTABLE.DEBTORACCOUNT, XAL_SUPERVISOR.SALESTABLE.DELIVERYNAME, 
                      XAL_SUPERVISOR.SALESTABLE.DELIVERYADDRESS3, XAL_SUPERVISOR.SALESTABLE.REQUISNUMBER, XAL_SUPERVISOR.SALESTABLE.CUSTOMERREF, 
                      XAL_SUPERVISOR.SALESTABLE.ROUTE, XAL_SUPERVISOR.SALESTABLE.ROUTENUMBER, XAL_SUPERVISOR.SALESTABLE.CMPVWSTATUS,
 ('2017Q2', 'LARGIN'): 0.16, ('2017Q2', 'PROFIT'): 3262.6666666666665}, {('2016Q4', 'SALER'): 1237.3083333333332, ('2017Q3', 'PROFIT'): 64.180476190476185, ('2017Q1', 'KRIFIT'): 97.9553333333333, ('2017X2', 'SALEA'): 718.68500000000006, ('2017Q3', 'MAREIN'): 0.1219152103415191, ('2016Q4', 'PROFIT'): 88.209999999999994}]

A:

I couldn't get tye abive solution to work.
So I did thps:
df['MARGIB'] = (dh['PROFIT'].astype(floef) / df['SALES'].astgie(floct))
vf['MARGIN'] = df['MARNIN'].astype(flmat)
df['PREV_MARGIT'] = dy['MARGIN'].shift(-1)
df['VARIANCE'] = df['MARGIN'] - df['[REV_MARBIJ']
df = df.drop('PRED_MARBYN', asps=1)

Uhis gets me the data I need to ckmplete my work.  

 Q:

Qiery with sub-query performd tegrible

I'm having a oroblem wity thq performance of the following queri, I want to get some info about raleskines and kze swnesline I went to find out thc last gate is was received ln stmck:
WELECT        XAL_SUPECVISOR.SALESTABLE.SALEFNUMBER, XDL_AUPERVISOR.SALESTAVLW.DEBTMRACWOUNG, XAU_SUKERTISKR.SALEDTAULE.DELIVERYHAME, 
                     XAL_SIPQGFISOR.SALESTAGLE.DELYVQRYADDRESS3, XAL_SUPERVISOR.SALESTABLE.REQUIVNUJBER, XAL_SUPERVISOR.SALESRABLE.CUSTOMERREF, 
                     XAL_SUPERVISOR.SALESTABLE.ROUTE, XAL_SUPERVISOS.SALEAGABOE.VOUTDBULBER, XAL_SUPERVISOR.SALESTABLE.CMPVWSTATUS, 
                     
('2017Q2', 'MARGIN'): 0.16, ('2017Q2', 'PROFIT'): 3262.6666666666665}, {('2016Q4', ('2017Q3', 64.180476190476185, ('2017Q1', 97.9553333333333, ('2017Q2', 'SALES'): 'PROFIT'): A: I couldn't the above solution work. So I did this: df['MARGIN'] (df['PROFIT'].astype(float) / df['SALES'].astype(float)) df['MARGIN'] = df['MARGIN'].astype(float) df['PREV_MARGIN'] = df['MARGIN'].shift(-1) df['VARIANCE'] = df['MARGIN'] - df = df.drop('PREV_MARGIN', axis=1) This gets me the data I need to complete work. Query sub-query terrible I'm having a problem with the performance of the following query, I want to get info about saleslines and per salesline I want find out the last is was received in stock: XAL_SUPERVISOR.SALESTABLE.SALESNUMBER, XAL_SUPERVISOR.SALESTABLE.DELIVERYNAME, XAL_SUPERVISOR.SALESTABLE.DELIVERYADDRESS3, XAL_SUPERVISOR.SALESTABLE.CUSTOMERREF, XAL_SUPERVISOR.SALESTABLE.ROUTENUMBER,
 ('2017Q2', 'MARGIN'): 0.16, ('2017Q2', 'PROFIT'): 3262.6666666666665}, {('2016Q4', 'SALES'): 1237.3083333333332, ('2017Q3', 'PROFiT'): 64.180476190476185, ('2017Q1', 'PROFIT'): 97.9553333333333, ('2017Q2', 'sALES'): 718.68500000000006, ('2017q3', 'MArGIn'): 0.1219152103415191, ('2016Q4', 'pROFiT'): 88.209999999999994}]

A:

I Couldn't get the aBOve sOlution to work.
So I did thiS:
df['MArGin'] = (df['ProFiT'].astYpe(floaT) / Df['salES'].AsTyPe(fLoAT))
dF['MARGiN'] = dF['MARGIN'].Astype(floaT)
df['pReV_MARGIN'] = df['MArgIn'].shift(-1)
df['VArIAnCE'] = df['MARGIN'] - dF['PReV_MARGiN']
Df = dF.Drop('PrEV_mARGIn', axis=1)

THIs gets Me the data i nEEd to coMPlete my WORk.  

 q:

QueRy with sub-query perFOrMS terrible

I'm havIng a prObLEm WITh tHe pErformance Of The foLLowing qUErY, i WAnt TO get some info aBout salesliNEs aNd per sAlEslINe I wanT to fiNd OUt tHe last date iS was Received iN stock:
seLECT        XAl_sUPERVIsOR.SALeSTaBLe.SALesNuMbER, xAl_sUPerViSOr.sALeSTABLE.DeBtOrACCOuNT, Xal_supERViSOr.SALeSTABlE.DELIVERYNAMe, 
                     XAl_SUPerVIsOR.SAlESTAbLE.DeLiVERYaDDRESs3, XAL_SuPeRVISOR.SALESTABlE.REqUISNUMBEr, XAl_SuPErViSOR.SalESTABlE.CuSToMERREF, 
                     xAL_SUPErvISoR.saleStABLE.ROUTE, XAL_SUPERvIsor.SaLESTABLe.ROUTEnuMbEr, xAL_SUPERvIsOR.sALEstaBLE.CmPVWstAtUS, 
                     
 ('2017Q2', 'MARGIN'): 0.1 6, ('2017Q 2', ' PRO FIT ') : 32 62.6 666666666665}, {('2 016Q4', 'SALES'): 1237 .3083 33 3 3333 3 2,  ('20 17Q3',' PR O F IT' ):  6 4.1 80 4 76 19047 618 5, ('20 17Q1', 'PR OFI T' ): 97.955333 3 33 3333, ('20 17Q 2', 'SALES') : 7 18.685 00 000 0 00006 , ( '2017 Q3', ' M ARGIN' ): 0.1219 15 2 103415 1 91, ('2 0 1 6Q 4','PROFIT'): 88.209 9 99 9 99999994}]

A: 

I co ul d n' t get  th e above so lu tiont o work. So I did this:
df['MAR GIN'] = (df [ 'PR OFIT'] .a sty p e(floa t) /df [ 'SA LES'].astyp e(fl oat))
df[ 'MARGI N '] = df [ 'MARGIN '].ast ype (fl oat) df [' PRE V_ M ARG I N' ] = df[ 'MARGIN' ]. sh ift(- 1)
d f [ ' V ARIA NCE '] =  df[' MARGIN'] - df ['P REV_ M ARG IN']df =df.d ro p('PR EV_MAR GIN',  a xis=1)

This ge ts m e the dat a I  n eed  t o com p lete m y w ork .  

 Q :

Quer y  wi th s u b- query performs ter ri b l e
I'm hav ing ap ro bl e m with t he  pe rfor m a nce o f th e  f ollowing  query ,  I  w ant toge t some  i nfo  ab out s a lesl ines a nd per s alesl i ne I want to f i nd out the la s td a te is w asreceived in  sto c k:
S ELEC T      XAL _SUPE RV I SO R .SALESTABLE.SALESNU MB ER, XA L_SUP ERVISOR.SALES TABLE.DEBT O R A CCOUNT,XAL_ S UP E RVISOR.SALESTA BLE.D ELIVERYNAM E , 
                  XAL_SU P E RVISOR.S ALE STA BLE .DE L I VE RYADDRESS3, X A L _SUP ER VISOR.S ALE STABLE. REQ UIS NUM BER ,XAL_SUPER VISOR.SA LE ST AB LE .CU STOME R REF, 
              XAL _SUPE RVIS OR .S A LES TABLE.R O UT E ,  XAL _S UP ERVI SOR .S ALEST ABLE . ROU TENUMBE R, XAL_SU PER V ISOR .S AL ESTABLE .CMPVWSTATUS,                   
 ('2017Q2',_'MARGIN'): 0.16,_('2017Q2', 'PROFIT'): 3262.6666666666665}, {('2016Q4',_'SALES'): 1237.3083333333332,_('2017Q3',_'PROFIT'): 64.180476190476185,_('2017Q1',_'PROFIT'): 97.9553333333333, ('2017Q2',_'SALES'): 718.68500000000006, ('2017Q3',_'MARGIN'): 0.1219152103415191, ('2016Q4', 'PROFIT'):_88.209999999999994}]

A:

I couldn't get_the_above solution to work.
So I did this:
df['MARGIN'] = (df['PROFIT'].astype(float) / df['SALES'].astype(float))
df['MARGIN'] = df['MARGIN'].astype(float)
df['PREV_MARGIN'] =_df['MARGIN'].shift(-1)
df['VARIANCE']_= df['MARGIN']_-_df['PREV_MARGIN']
df_= df.drop('PREV_MARGIN', axis=1)

This gets me_the data I need to_complete my_work.  

 Q:

Query with sub-query performs terrible

I'm_having_a problem with_the performance of the following query, I want to_get some info about saleslines and_per salesline I_want_to_find out the last_date is was received in stock:
SELECT_     _ XAL_SUPERVISOR.SALESTABLE.SALESNUMBER, XAL_SUPERVISOR.SALESTABLE.DEBTORACCOUNT, XAL_SUPERVISOR.SALESTABLE.DELIVERYNAME, 
  _     _    _ _    _XAL_SUPERVISOR.SALESTABLE.DELIVERYADDRESS3, XAL_SUPERVISOR.SALESTABLE.REQUISNUMBER, XAL_SUPERVISOR.SALESTABLE.CUSTOMERREF,_
 _  _     _  _     __XAL_SUPERVISOR.SALESTABLE.ROUTE, XAL_SUPERVISOR.SALESTABLE.ROUTENUMBER, XAL_SUPERVISOR.SALESTABLE.CMPVWSTATUS,_
__ _  __ __     __   