I have a huge table called 'Sales` with these areas
Time | Product | amount | customerid
Date1 | Product1 | 2 | 2
Date1 | Product2 | 5 | 3
Date1 | Product1 | 6 | 3
Date1 | Product4 | 1 | 3
Date2 | Product1 | 2 | 1
Date2 | Product1 | 2 | 4
Date2 | Product3 | 3 | 4
Date2 | Product3 | 3 | 1
Now, I want to get a most popular product each day.
SELECT Time,
Product,
SUM(amount) AS Total
FROM Sales
GROUP BY Time, Product
Gives me the following
Time | Product | total
Date1 | Product1 | 8
Date1 | Product2 | 5
Date1 | Product4 | 1
Date2 | Product1 | 4
Date2 | Product4 | 6
In which way I have to change my query, to get just the top seller products of each day?
EDIT: Thanks a lot for your solutions, but it doesn't work.
I want to summerize, which product is a top seller of each day
Time | Product | total
Date1 | Product1 | 8
Date2 | Product4 | 6
Stuff like 'LIMIT 1' just show me the first row, but not all!