Hello everyone
I have a problem. I'm doing a turnover report by year. But we have changed our datastructure per 2016. How do i get our TOTALSALES per SalesYear when i want to differ the SQL Query if the salesyear is 2016 or later.
//My Query that gets sales before 2016:
SELECT SUM([Cust. Ledger Entry ].[Sales (LCY)]) AS TotalSales, YEAR([Cust. Ledger Entry ].[Posting Date]) AS SalesYear
FROM[Cust. Ledger Entry ] INNER JOIN
Customer ON [Cust. Ledger Entry ].[Customer No.] = Customer.[No.]
WHERE ([Cust. Ledger Entry ].[Customer No.] <> '80501608') AND (Customer.[Gen. Bus. Posting Group] IN ('OFFSH EU', 'OFFSH Ø', 'OFFSH DK', 'FISK ØV', 'FISK EU', 'FISK DK', 'ØVRIG ØV', 'ØVRIG EU', 'ØVRIG DK', 'SLAM EU', 'SLAM DK', 'SLAM ØV', 'FØDE DK', 'FØDE EU', 'FØDE ØV')) AND
([Cust. Ledger Entry ].[Document Type] IN ('2', '3')) AND (YEAR([Cust. Ledger Entry ].[Posting Date]) < '2016')
GROUP BY YEAR([Cust. Ledger Entry ].[Posting Date])
ORDER BY SalesYear
//My Query that gets sales after 2016:
SELECT SUM([Credit Amount] - [Debit Amount]) AS TotalSales, YEAR([Posting Date]) AS SalesYear
FROM [G/L Entry]
WHERE ([G/L Account No.] IN ('100210', '100220', '100230', '100260', '100270', '100280', '100310', '100320', '100330', '100360',
'100370', '100380', '100410', '100420', '100430'))
GROUP BY YEAR([Posting Date])
ORDER BY SalesYear
How on earth do i get the data returned together?
What I have tried:
I have tried to use UNION but i can't get this working.