Thursday, March 24, 2011

GLOBAL(NET OUSTANDING DETAILS)

Select Sauda.Oowncode as Oowncode, Sauda.Compcode as Compcode,' ' as Ndel, Rpad(' ',20) as Companyname, Sauda.Exchcode as Exchcode,Sauda.Egroup as
Egroup,Rpad(' ',20) as Booktype,Sauda.Vallan as Vallan, Sum(Decode(Sauda.Buysell,'B',Decode(Sauda.Saudatype,'N' ,0,Sauda.Quantity),0)) as
Purchqty,Sum(Decode(Sauda.Buysell,'B',Decode(Sauda.Saudatype,'N', (Sauda.Final_rat1-Sauda.Havala_rate)*Sauda.Quantity,Sauda.Quantity*Sauda.Final_rat1),0))
as Purchvalue,Sum(Decode(Sauda.Buysell,'S',Decode(Sauda.Saudatype,'N' ,0,Sauda.Quantity),0)) as
Salesqty,Sum(Decode(Sauda.Buysell,'S',Decode(Sauda.Saudatype,'N' , (Sauda.Final_rat1-Sauda.Havala_rate)*Sauda.Quantity,Sauda.Quantity*Sauda.Final_rat1),0))
as Salesvalue,Sum(Decode(Sauda.Saudatype,'N' ,0,Decode(Sauda.Buysell,'B',Sauda.Quantity*1,Sauda.Quantity*-1))) as Netqty,
Sum(Decode(Sauda.Buysell,'B',Decode(Sauda.Saudatype,'N' , (Sauda.Final_rat1-Sauda.Havala_rate)*Sauda.Quantity,Sauda.Quantity*Sauda.Final_rat1),
Decode(Sauda.Saudatype,'N' ,(Sauda.Final_rat1-Sauda.Havala_rate)*Sauda.Quantity*-1, Sauda.Quantity*Sauda.Final_rat1*-1))) as Netvalue, 0.00 as Paverage,0.00
as Saverage,0.00 as Naverage,0.00 as Market,0.00 as Markvalue,0.00 as Proloss,Sauda.Dtoftran as Saudadate From Sauda Sauda Where Sauda.Egroup!='FU' and
Sauda.Sterminal!='99999' and Sauda.Firmnumber='ACML-00001' and Oowncode='570058312' Group by
Sauda.Oowncode,Sauda.Compcode,Sauda.Exchcode,Sauda.Egroup,Sauda.Vallan,Sauda.Dtoftran
Union All
Select Billcharges.Oowncode as Oowncode,Billcharges.Compcode as Compcode,' ' as Ndel, Rpad(' ',20) as Companyname, Billcharges.Exchcode as
Exchcode,Billcharges.Egroup as Egroup,Rpad(' ',20) as Booktype,Billcharges.Vallan as Vallan, Sum(Billcharges.Quantity) as
Purchqty,Sum(Billcharges.Quantity*Billcharges.Final_rat1) as Purchvalue, 0 as Salesqty,0 as Salesvalue,Sum(Billcharges.Quantity) as
Netqty,Sum(Billcharges.Quantity*Billcharges.Final_Rat1) as Netvalue, 0.00 as Paverage,0.00 as Saverage,0.00 as Naverage,0.00 as Market,0.00 as
Markvalue,Sum(Billcharges.Quantity*Billcharges.Final_rat1*-1) as Proloss,Billcharges.Dtoftran as Saudadate From Billcharges Billcharges Where
Billcharges.Parent!='Y' and Billcharges.Egroup!='FU' and Billcharges.Firmnumber='ACML-00001' and Oowncode='570058312' Group by
Billcharges.Oowncode,Billcharges.Compcode,Billcharges.Exchcode,Billcharges.Egroup,Billcharges.Vallan,Billcharges.Dtoftran;

No comments:

Post a Comment

Followers