Hi all,
I have a problem of how I can roll up 3 columns (accountname,Debit_Total, and Credit_Total) in SAP B1 query.
This is my query
SELECT T2.[AcctCode],T2.[acctname], sum(T1.[Debit])as Debit_Total,sum(T1.[Credit]) as Credit_Total
FROM [dbo].[JDT1] T1 INNER JOIN [dbo].[OACT] T2 ON T1.Account = T2.AcctCode
WHERE T1.[RefDate] >='10/12/2014' and T1.[RefDate] <='01/02/2015'
GROUP BY T2.[AcctCode] , T2.[acctname] with rollup
union all
SELECT T1.[AcctCode] ,acctname=(select acctname from [dbo].[OACT] where acctcode=t1.acctcode),T3.[Debit] , T3.[Credit]
FROM [dbo].[OQUT] T0 INNER JOIN [dbo].[QUT1] T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN [dbo].[OACT] T2 ON T0.[CtlAccount] = T2.[AcctCode] INNER JOIN JDT1 T3 ON T2.[AcctCode] = T3.[Account]
WHERE T0.[DocDate] >='10/12/2014' and T0.[TaxDate]<='01/02/2015'
the result looks like this
As it seems accountname is correct, but Debit_Total or Credit_Total do not accept roll up except that they duplicate each rows.
So how can I rollup Debit_Total and Credit_Total in my query?
Please anyone can help me.
