isuckatsql (5/1/2014)
select top 15 count(*) as cnt, state from tablegroup by state
order by cnt desc
select top 15 count(*) as cnt, city from table
group by city
order by cnt desc
select top 15 count(*) as cnt, company from table
group by company
order by cnt desc
Can the above three queries be combined into one and still be fast, if so how?
What i am trying to go is an item count, by group, similar to ones Inbox in Outlook.
Thanks
I want to see your expected output. If New York City is the most populous city but California is the most populous state, how would a single output with the respective columns and counts portray that? NYC is in NY, not CA...
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service