supportservice
Technical User
- Mar 12, 2012
- 63
Hello,
I have this UNION query but need to have the totals summed when the MainAccountDesc is the same.
RESULT:
It should be combined not two separate lines.
I'm not sure how to do that?
I have this UNION query but need to have the totals summed when the MainAccountDesc is the same.
Code:
SELECT RotocoSummary.AccountCategoryDesc, RotocoSummary.MainAccountDesc, RotocoSummary.MTD, RotocoSummary.LMTD, RotocoSummary.YTD, RotocoSummary.LYTD
FROM RotocoSummary LEFT JOIN SB1Summary ON (RotocoSummary.MainAccountDesc = SB1Summary.MainAccountDesc) AND (RotocoSummary.AccountCategoryDesc = SB1Summary.AccountCategoryDesc)
UNION SELECT SB1Summary.AccountCategoryDesc, SB1Summary.MainAccountDesc, SB1Summary.MTD, SB1Summary.LMTD, SB1Summary.YTD, SB1Summary.LYTD
FROM RotocoSummary LEFT JOIN SB1Summary ON (RotocoSummary.MainAccountDesc = SB1Summary.MainAccountDesc) AND (RotocoSummary.AccountCategoryDesc = SB1Summary.AccountCategoryDesc);
RESULT:
Code:
AccountCategoryDesc MainAccountDesc MTD LMTD YTD LYTD
Assets ACCUMULATED DEPRECIATION 0 3316.17 10149.61 13264.68
Assets ACCUMULATED DEPRECIATION 0 21615.27 23158 86461.08
It should be combined not two separate lines.
I'm not sure how to do that?