--这样? select * from (select 城市,cnt=count(1) from 表名 group by 城市)a order by cnt desc
select TOP 3 城市 from (select 城市,count(1) num from 表名 group by 城市) a order by num desc
select top 3 dname from (select 1 did ,'上海' dname union all select 2 ,'北京' union all select 3,'上海' union all select 4, '北京' union all select 5,'上海' union all select 6 ,'北京' union all select 7,'南京' union all select 8 ,'北京' union all select 7,'南京' union all select 8 ,'郑州') agroup by dname order by count(dname) desc
按一楼的。再加一个TOP选择前三就好了。
select * from (select top 3 address,cnt=count(1) from pageVisits group by address)a order by cnt desc 是这样 谢谢了 结贴
--这样?
select * from
(select 城市,cnt=count(1) from 表名 group by 城市)a
order by cnt desc
from (select 城市,count(1) num from 表名 group by 城市) a
order by num desc
select top 3 dname
from
(select 1 did ,'上海' dname
union all
select 2 ,'北京'
union all
select 3,'上海'
union all
select 4, '北京'
union all
select 5,'上海'
union all
select 6 ,'北京'
union all
select 7,'南京'
union all
select 8 ,'北京'
union all
select 7,'南京'
union all
select 8 ,'郑州') agroup by dname
order by count(dname) desc
(select top 3 address,cnt=count(1) from pageVisits group by address)a
order by cnt desc
是这样 谢谢了 结贴