Skip to Content
0
Former Member
Jul 07, 2010 at 03:00 AM

Calculation from UNION query

24 Views

Hi Experts,

I have the following query:

SELECT SUM(T0.SYSDeb - T0.SYSCred) AS 'Production'
FROM JDT1 T0 INNER JOIN OJDT T1 ON T0.TransId = T1.TransId
WHERE T0.Account in ('_SYS00000000238','_SYS00000000239','_SYS00000000244') AND T1.RefDate >= [%0] AND T1.RefDate <= [%1]

UNION

SELECT SUM(T0.SYSDeb - T0.SYSCred) AS 'Production'
FROM JDT1 T0 INNER JOIN OJDT T1 ON T0.TransId = T1.TransId
WHERE T0.Account = '_SYS00000000053' AND T1.RefDate >= [%0] AND T1.RefDate <= [%1]

I need to add a new Union to show the First 'select' result minus the Second 'select' result. Then I need to also show this as a persentage in another Union underneath.

Any help would be appreciated.

Marli