I have a SQL Query which gets gets top 5 sold items at a given store.
SELECT TOP 5 S.UPCCode, SUM(TotalDollarSales) FROM Sales S WHERE S.StoreId = 1 GROUP BY S.UPCCode ORDER BY SUM(S.TotalDollarSales) desc
The Sales table has -> UPCCode, SaleDate, StoreId, TotalDollarSales
I am looking for a query which will return me Top 5 items sold for each of the stores in a single query. I can write multiple queries and use a union but it doesn't seem efficient.
How can I get the top 5 sold items for each store in a single query.
Thanks in advance.
0 answers
Hot tools Tags
Hot Questions
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
20522
7
13634
4






