-
April 14th, 2010, 05:11 AM
#1
Sum column in one table with different criteria
Hi,
Could anyone advise how to select in one query instead of two??
SELECT T0.DocDate, SUM (T1.[LineTotal]) as "APBASE", ROUND((sUM(T1.LineTotal)*0.07),2) AS "APGST"
FROM OPCH T0 INNER JOIN PCH1 T1
ON T0.DocEntry = T1.DocEntry and T1.ItemCode NOT IN ('CARRY FEE', 'carry fee (packing)', 'LABOUR', 'CUSTOMS', 'TRANSPORT')
AND T0.U_PermitNos = 'IG4555' AND T0.DocType = 'I' group by t0.docdate
SELECT T1.LineTotal, T0.U_YS_GSTBaseAmt FROM OPCH T0 INNER JOIN PCH1 T1
ON T0.DocEntry = T1.DocEntry
AND T0.U_PermitNos = 'IG4555' AND T0.DocType = 's'
-
April 14th, 2010, 08:28 PM
#2
Re: Sum column in one table with different criteria
Hi, there are some changes to the codes
SELECT T0.DocDate, SUM (T1.[LineTotal]) as "APBASE", ROUND((sUM(T1.LineTotal)*0.07),2) AS "APGST"
FROM OPCH T0 INNER JOIN PCH1 T1
ON T0.DocEntry = T1.DocEntry and T1.ItemCode NOT IN ('CARRY FEE', 'carry fee (packing)', 'LABOUR', 'CUSTOMS', 'TRANSPORT')
AND T0.DocType = 'I' group by t0.U_permitnos
The above script will sum up all the document grp by the permitnos.....
SELECT T1.LineTotal, T0.U_YS_GSTBaseAmt FROM OPCH T0 INNER JOIN PCH1 T1
ON T0.DocEntry = T1.DocEntry
AND T0.DocType = 's'
For the above script, it only have one document per PermitNos....
Kindly advise...thanks...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|