Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have table like this
table name ssssss
in that column names r
SQL
state     coverage
 aa         a1
 aa         a2
 aa         a3
 bb         a1
 bb         a4
 cc         a1
 cc         a6

here state names are aa,bb,cc and aa having 3 coverage
bb having 2 coverages
cc having 2 coverages
inthat we want which state have maximum no of coverages , with count

[Edit]Shouting removed[/Edit]
Posted
Updated 12-Feb-13 2:36am
v3

1 solution

have not tried must this should be close...
SQL
select top 1 state, count(coverage) as cnt
from ssssss
group by state
order by  count(coverage) desc 
 
Share this answer
 
Comments
Bandi Ramesh 12-Feb-13 8:43am    
Guirec Le Bars... your query works perfect in SQL
Guirec 12-Feb-13 8:46am    
sql engines are usually very good at interpreting....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900