IF I consider 'PREVMNTPV' is one table and 'CURR' is other table and 'CURR' table consists of field1,field2,fied3 and field4. How do I get the below excel formaules to SQL. Please help me out...
col1/field1=IF(T2="Inactive",0,IF(AND(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:B,2,FALSE)),BL2=1),1,IF(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:B,2,FALSE)),0,IF(AND(BL2=1,VLOOKUP($A2,'PREVMNTPV'!A:E,5,FALSE)="Inactive",T2="Active"),1,IF(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:B,2,FALSE)),0,IF(AND(BL2=1,VLOOKUP($A2,'PREVMNTPV'!A:F,6,FALSE)=0),1,0))))))
col2/field2=IF(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:B,2,FALSE)),0,IF(AND(T2="Inactive",VLOOKUP($A2,'PREVMNTPV'!A:K,6,FALSE)=1,VLOOKUP($A2,'PREVMNTPV'!A:E,5,FALSE)="Active"),-1,IF(AND(VLOOKUP($A2,'PREVMNTPV'!A:K,6,FALSE)=1,BL2=0,VLOOKUP($A2,'PREVMNTPV'!A:E,5,FALSE)="Inactive"),0,IF(AND(BL2=0,VLOOKUP($A2,'PREVMNTPV'!A:K,6,FALSE)=1),-1,0))))
col3/field3=IF(OR(T2="Inactive",DI2<0),0,IF(DG2=-1,0,IF(DF2=1,BT2,IF(ISNA(VLOOKUP(A2,'PREVMNTPV'!A:K,8,FALSE)),BT2,IF(AND(BL2=1,(VLOOKUP(A2,'PREVMNTPV'!A:K,8,FALSE)<BT2)),BT2-(VLOOKUP(A2,'PREVMNTPV'!A:K,8,FALSE)),0)))))
col4/field4=IF(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:E,3,FALSE)),0,IF(AND($T2="Inactive",VLOOKUP($A2,'PREVMNTPV'!A:E,5,FALSE)="Inactive"),0,IF(DG2=-1,-1*(VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE)),IF(AND(BT2<VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE),T2="Active"),BT2-(VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE)),IF(BT2-(VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE)>0),0,BT2-(VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE)))))))
col1/field1=IF(T2="Inactive",0,IF(AND(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:B,2,FALSE)),BL2=1),1,IF(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:B,2,FALSE)),0,IF(AND(BL2=1,VLOOKUP($A2,'PREVMNTPV'!A:E,5,FALSE)="Inactive",T2="Active"),1,IF(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:B,2,FALSE)),0,IF(AND(BL2=1,VLOOKUP($A2,'PREVMNTPV'!A:F,6,FALSE)=0),1,0))))))
col2/field2=IF(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:B,2,FALSE)),0,IF(AND(T2="Inactive",VLOOKUP($A2,'PREVMNTPV'!A:K,6,FALSE)=1,VLOOKUP($A2,'PREVMNTPV'!A:E,5,FALSE)="Active"),-1,IF(AND(VLOOKUP($A2,'PREVMNTPV'!A:K,6,FALSE)=1,BL2=0,VLOOKUP($A2,'PREVMNTPV'!A:E,5,FALSE)="Inactive"),0,IF(AND(BL2=0,VLOOKUP($A2,'PREVMNTPV'!A:K,6,FALSE)=1),-1,0))))
col3/field3=IF(OR(T2="Inactive",DI2<0),0,IF(DG2=-1,0,IF(DF2=1,BT2,IF(ISNA(VLOOKUP(A2,'PREVMNTPV'!A:K,8,FALSE)),BT2,IF(AND(BL2=1,(VLOOKUP(A2,'PREVMNTPV'!A:K,8,FALSE)<BT2)),BT2-(VLOOKUP(A2,'PREVMNTPV'!A:K,8,FALSE)),0)))))
col4/field4=IF(ISNA(VLOOKUP($A2,'PREVMNTPV'!A:E,3,FALSE)),0,IF(AND($T2="Inactive",VLOOKUP($A2,'PREVMNTPV'!A:E,5,FALSE)="Inactive"),0,IF(DG2=-1,-1*(VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE)),IF(AND(BT2<VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE),T2="Active"),BT2-(VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE)),IF(BT2-(VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE)>0),0,BT2-(VLOOKUP($A2,'PREVMNTPV'!A:K,8,FALSE)))))))