Skip to content
Advertisement

SQL Top 10 Sales Every Month

Greeting all. I have a SQL 2008 express database, lets name is tbl_Merchant, similar as following:

I need to find the top 10 merchant with sales every month over 12 months.

It is very easy if it is just one month.

But I am stuck if I wan to find them over 12 months. I need to display 120 merchants, which are top 10 sales merchant of each month. Currently my solution is to union 12 tables from month 1 to 12 together but I don’t think it is a good way.

Can any one kindly give me any suggestion?

Thank you very much.

Advertisement

Answer

Valid for Sql Server 2005+

Try this for overall:

OR

if you need details per month for top 10 PER MONTH

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement