سؤال

I have a query that looks like so:

SELECT Name, SUM(Price * Quantity) AS Total
FROM Sales  
WHERE Date = " + ddItems.SelectedItem + "
GROUP BY Name

How can I show the top 10 totals?

هل كانت مفيدة؟

المحلول

In MySQL the number of rows can be limited with the LIMIT clause, so you can add this to your query to get the top 10:

ORDER BY Total DESC
LIMIT 10
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top