select top 100 ip from count group by ip order by count(id) desc?
select top 100 ip from [count] group by ip order by count(id) desc
select ip from [count] group by ip order by count(id) desc
select top 100 ip from count group by ip order by count(id) desc
如果分组再加条件的话要如何写?如sql="select ip from count group by ip order by count(id) desc 改为 sql="select ip from count group by ip where ip='127.0.0.1' order by count(id) desc" 出错..
sql="select ip from count group by ip having ip='127.0.0.1' order by count(id) desc"
如果分组再加条件的话要如何写?...group by having 条件
为什么不能分组选取两个字段?sql="select ip,hostname from count group by ip having ip='127.0.0.1' order by count(id) desc"以上要如何写呢?
sql="select ip,hostname from count group by ip,hostname having ip='127.0.0.1' order by count(id) desc"
from [count]
group by ip
order by count(id) desc
select top 100 ip from count group by ip order by count(id) desc
改为
sql="select ip from count group by ip where ip='127.0.0.1' order by count(id) desc"
出错..
1 1 a1
2 1 a2
3 2 b1
4 1 a3
5 3 c1
6 2 b2
7 2 b3
8 3 c2GROUP出来的ClassID为 1,2,3
如果取头2个,是取1,2或是2,3,或是1,3? 确定了这个才能确定取哪些记录.
我举的例子恰好分组的列是INT,可以随意ORDER BY,但如果像某些部门的名称来分组呢? 不会是按首拼音吧, 这样排起来没目的性.