取第一条即可 SELECT count(*) as degree,b,date1 from test group by date1 order by degree desc;
select s.b,dates,m from (select b,max(c) as m from (select b,dates,count(b) as c from tb1 group by b,dates) q group by b) s, (select b,dates,count(b) as c from tb1 group by b,dates) t where s.m=t.c and s.b=t.b
from test group by a HAVING COUNT(*)>1
1 b1 2005-11-7
2 b1 2005-11-7
3 b4 2005-11-8
4 b1 2005-11-8
5 b2 2005-11-9
6 b1 2005-11-9
7 b1 2005-11-10
8 b1 2005-11-10
9 b1 2005-11-10可以看出b1在2005-11-10出现了3次,是最大数据,我要的就是这个
SELECT count(*) as degree,b,date1
from test group by date1 order by degree desc;
from (select b,max(c) as m
from (select b,dates,count(b) as c
from tb1
group by b,dates) q
group by b) s,
(select b,dates,count(b) as c
from tb1
group by b,dates) t
where s.m=t.c and s.b=t.b
1 b1 2005-11-7
2 b1 2005-11-7
3 b4 2005-11-8
4 b1 2005-11-8
5 b2 2005-11-9
6 b1 2005-11-9
7 b1 2005-11-10
8 b1 2005-11-10
9 b1 2005-11-10
10 b2 2005-11-10
11 b2 2005-11-10
13 b3 2005-11-10
14 b1 2005-11-10可以看出b1在2005-11-10出现了4次,是最大数据,我要按时间和b字段同时分组查询,最好是返回所有列?