How do I go about getting two different where conditions in my SELECT statement, so I can get the SUM grouped by month?
SELECT
[tpdb].[tLedgerEntry].CalendarMonth AS Måned,
(select SUM(Amount) FROM [tpdb].[tLedgerEntry] where CompanyId = 'Nordlux A/S' and CalendarYear = 2018 and LedgerAccount>=6001 and LedgerAccount <= 6090) AS Varelager,
(select SUM(Amount) FROM [tpdb].[tLedgerEntry] where CompanyId = 'Nordlux A/S' and CalendarYear = 2018 and LedgerAccount>=6100 and LedgerAccount <= 6156) AS Debitorer
FROM [tpdb].[tLedgerEntry]
GROUP BY [tpdb].[tLedgerEntry].CalendarMonth
This is the result I'm getting now which is wrong.
NULL 32582633.07 13901648.50
1 32582633.07 13901648.50
2 32582633.07 13901648.50
3 32582633.07 13901648.50
4 32582633.07 13901648.50
5 32582633.07 13901648.50
6 32582633.07 13901648.50
7 32582633.07 13901648.50
8 32582633.07 13901648.50
9 32582633.07 13901648.50
10 32582633.07 13901648.50
11 32582633.07 13901648.50
12 32582633.07 13901648.50