Reputation: 99
I want the top 5 products from a table
If i use this
SELECT MAX(ProductCode) AS ProductName
FROM OrderDetails
I get only one result I want the top 5 result
Upvotes: 0
Views: 3043
Reputation: 99
solved..by using this query
SELECT TOP 5 ProductName, COUNT(ProductName) AS value_occurrence FROM OrderDetails GROUP BY ProductName ORDER BY value_occurrence DESC
Upvotes: 2
Reputation: 30665
Try this for MySQl
SELECT ProductCode FROM OrderDetails
ORDER BY ProductCode Desc
LIMIT 5
Upvotes: 2