Skip to Content
0
Jan 30 at 12:06 PM

Query needed for Top 10 suppliers in 2022

38 Views

Hi, I have a query that shows top 10 suppliers and customers and it gives a total of how much we spent with them however, I need to take it a stage further and calculate how much was spent in just 2022.

Any ideas?

This is what I have at the moment, but doesn't restrict it to just 2022.

SELECT TOP 10 T0.[CardCode], T0.[Balance],ISNULL(CONVERT(NVARCHAR(100),T0.[AliasName]),T0.[CardName])

FROM OCRD T0

WHERE T0.[CardType] = '[%0]'

ORDER BY CASE WHEN T0.[CardType] = 'C' THEN T0.[Balance] END DESC,CASE WHEN T0.[CardType] = 'S' THEN T0.[Balance] END ASC

Thanks