I'm not sure what to search for on this question, so I'm just going to ask the question.
I have two queries built and I want the results to combine the AccountRef_FullName categories together.
Here is the first query:
Here is the second query:
When I run these two queries with a "UNION ALL"
this is the current result I'm getting:
In the results above, the resulting line "Services:Tank Service 210" is the only thing coming from the second query (which is correct). However, I would like the results from query one to be combined with the results from query two when the AccountRef_FullName is the same.
So the desired results would look like this:
Can anyone point me in the right direction on getting this result? Thanks!
I have two queries built and I want the results to combine the AccountRef_FullName categories together.
Here is the first query:
Code:
SELECT SOPD.AccountRef_FullName, SUM(ILD.Amount) AS SumTotal
FROM invoicelinedetail ILD
INNER JOIN Invoice ON ILD.IDKey = Invoice.TxnID
INNER JOIN ItemService ON ItemService.ListID = ILD.ItemRef_ListID
INNER JOIN SalesorPurchaseDetail SOPD ON SOPD.IDKEY = ItemService.ListID
WHERE (Invoice.TxnDate >= '2/1/2008' AND Invoice.TxnDate <= '3/1/2008')
GROUP BY SOPD.AccountRef_FullName
Here is the second query:
Code:
SELECT SOPD.AccountRef_FullName, SUM(ABS(CMLD.Amount)) AS SumTotal
FROM creditmemolinedetail CMLD
INNER JOIN CreditMemo ON CMLD.IDKey = CreditMemo.TxnID
INNER JOIN ItemService ON ItemService.ListID = CMLD.ItemRef_ListID
INNER JOIN SalesorPurchaseDetail SOPD ON SOPD.IDKEY = ItemService.ListID
WHERE CreditMemo.TxnDate >= '2/1/2008' AND CreditMemo.TxnDate <='3/1/2008'
GROUP BY SOPD.AccountRef_FullName
ORDER BY SOPD.AccountRef_FullName
When I run these two queries with a "UNION ALL"
this is the current result I'm getting:
Code:
AccountRef_FullName SumTotal
Services:Disposal Fee 3703
Services:Other Services 370
Services:Recovery 17725
Services:Tank Service 210
Services:Tank Service 8398
In the results above, the resulting line "Services:Tank Service 210" is the only thing coming from the second query (which is correct). However, I would like the results from query one to be combined with the results from query two when the AccountRef_FullName is the same.
So the desired results would look like this:
Code:
AccountRef_FullName SumTotal
Services:Disposal Fee 3703
Services:Other Services 370
Services:Recovery 17725
Services:Tank Service 8608
Can anyone point me in the right direction on getting this result? Thanks!