Skip to Content
0
Former Member
Aug 27, 2009 at 08:07 AM

Problem in Sales Order Query

49 Views

Hi All,

I have problem....This is query which ic combination of Sales Order, Return, Delivery and AR Invoice.....Please tell me why this query is not working ......I want Document No, Quantity, Doc Date from Sales Order, Return, Delivery and AR Invoice and Tax bifergation also.....I per my view this query there should not be any problem but it is not working...please tell me where I am wrong....Just copy and paste this query and check in ur system.......

SELECT b.Doc_Num1 as 'SO. No.',
b.DocDate    as      'SO. Date', 
b.Doc_Num2   AS      'Del.Doc.No.',
b.DocDate    AS      'Delivery Date',
b.Doc_Num3   as      'A/R Invoice No.', 
b.DocDate    as 	'Inv. Date', 
b.Doc_Num4   AS 	'RETURN Doc.No.',
b.DocDate    as 	'Ret.Date',
b.CardName   as 	'Vendor Name',
b.NumAtCard  as 	'Bill No. & Date',
b.ItemCode   as 	'Item Code',
b.Dscription as 	'Dscription',
b.Quantity1  as 	'AR Invoice Quantity',
b.Quantity2  as 	'Sales Order Quantity',
b.Quantity3  as 	'Delivery Quantity',
b.Quantity4  as 	'Return Quantity',
b.LineTotal  as 	'Base Amt.(Rs.)',
b.WTSum	      AS 	'TDS (Rs.)', 
b.DocTotal    as	'Total (Rs.)',
sum(b.BED)    as 	     'Bed Value', 
sum(b.EDCS)   as	     'EDCS Value', 
sum(b.HECS)   as	     'HECS Value', 
sum(b.VAT) 	  as 		'VAT Value', 
sum(b.CST) 	  as		 'CST Value', 
sum(b.CVD) 	  as	 	'CVD Value', 
sum(b.SerTax)  as	 	'SERTAX Value', 
sum(b.CSonSerTax) as	 'CS Value', 
sum(b.HECS_ST)	 as	 'HESC Value'  
from (
select *,( a.Bed + a.EDCS + a.HECS + a.VAT + a.CST +a.CVD + a.SerTax + a.CSonSerTax  + a.HECS_ST ) as Filter from (SELECT distinct 
T0.DocNum,
T0.DocDate,
T2.DocNum,
T2.DocDate,
M.DocNum,
M.DocDate,
M.CardName,
M.NumAtCard,
L.ItemCode,
L.Dscription,
L.Quantity, 
T1.Quantity, 
T3.Quantity, 
S.DocNum, 
S.DocDate, 
X.Quantity, 
L.LineTotal,
M.DocEntry,
M.[DiscSum],
M.WTSum,
M.DocTotal,
M.WTSum, 
M.DocTotal,