I want to report information in this manner. I want to include only the top 3 occurrences of customers of each vertical market but I want to include 3 from each vertical market. So I have a population like the following:
verticalmarket, shiptoname
I want to create a select statement where the results are like the following:
Vertical Market A John's Meats 10,000
Vertical Market A Bill's Poultry 8,000
Vertical Market A Jill's Pastry 6,000
Vertical Market B ACME Produce 12,000
Vertical Market B BB Meats 9,500
Vertical Market B CC Steaks 2,500
But if I do the following:
select top 3 verticalmarket,shiptoname,count(*)
from table1
group by verticalmarket,shiptoname
order by verticalmarket asc,shiptoname asc,count(*) desc
will only give me the top 3 occurrences of all the records not in each vertical market. Can anyone suggest how to get the results I am looking for (top 3 for each vertical market) in one sql statement?
verticalmarket, shiptoname
I want to create a select statement where the results are like the following:
Vertical Market A John's Meats 10,000
Vertical Market A Bill's Poultry 8,000
Vertical Market A Jill's Pastry 6,000
Vertical Market B ACME Produce 12,000
Vertical Market B BB Meats 9,500
Vertical Market B CC Steaks 2,500
But if I do the following:
select top 3 verticalmarket,shiptoname,count(*)
from table1
group by verticalmarket,shiptoname
order by verticalmarket asc,shiptoname asc,count(*) desc
will only give me the top 3 occurrences of all the records not in each vertical market. Can anyone suggest how to get the results I am looking for (top 3 for each vertical market) in one sql statement?