У меня есть два оператора выбора, моя цель - отобразить сумму счета и сумму штрафа. Можно ли это сделать с помощью объединений?
SELECT SUM([Amount]) AS 'BILLING',(SELECT SUM([Amount])
FROM Transactions
WHERE CAST([TransactionDate] AS DATE)>(SELECT TOP 1 CAST([TransactionDate] AS DATE)
FROM Transactions WHERE CustNo = 6313 AND [Particulars]='Payment' ORDER BY [Id] DESC)
AND [CustNo]=6313
AND [Particulars]='Penalty') AS 'PENALTY'
FROM Transactions
WHERE CAST([TransactionDate] AS DATE)>(SELECT TOP 1 CAST([TransactionDate] AS DATE)
FROM Transactions WHERE CustNo = 6313
AND [Particulars]='Payment' ORDER BY [Id] DESC)
AND [CustNo]=6313
AND [Particulars]='Billing'