I'm trying to create a query which provides me with a list of the top 20 suppliers of our company. This information is stored in an MSSQL database.
I can count the number of orders against each supplier and list them by using group. I would then like to order this descending, so I see the top 20 suppliers and limit it so the others are disguarded.
As soon as I add the order function I get an error.
Can anyone tell me where I'm going wrong?
SELECT CardCode, COUNT(*) AS POs
WHERE (DocDate >= '06/01/2009') AND (DocDate <= '06/30/2009')
ORDER BY POs DESC
GROUP BY CardCode