Reputation: 355
I have a query that I would like to total the purchases from all Vendors by Year. However, my results are not coming back summed by vendor like I want. I believe it is because I have to put IJDATE in the GROUP BY. Any suggestions how I can fix this?
SELECT
YEAR(ij.IJDATE) AS YearPurchased,
ISNULL(SUM(ij.IJCOST * ij.IJQTY), 0) AS YearlySpend,
IJVEND AS Vendor
FROM
dbo.S2K_IJ ij
WHERE
ij.IJTYPE IN ('I', 'ID')
GROUP BY
ij.IJDATE,
ij.IJVEND
ORDER BY
YearPurchased,
Vendor
Upvotes: 0
Views: 28
Reputation: 56755
Try changing your Group By to this:
GROUP BY
YEAR(ij.IJDATE),
ij.IJVEND
Upvotes: 1