group by 多个字段

insert into test values(1,'a','甲')
insert into test values(1,'a','甲')
insert into test values(1,'a','甲')
insert into test values(1,'a','甲')
insert into test values(1,'a','乙')
insert into test values(1,'b','乙')
insert into test values(1,'b','乙')
insert into test values(1,'b','乙')

 

select count(a),b,c from test group by c,b;

 

以c列分组:

  第一组:1-5

  第二组:6-8

以b列分组:

  第一组:1-4

  第二组:5

  第三组:6-8

posted on 2013-06-06 21:26  Knuth_档案  阅读(216)  评论(0编辑  收藏  举报

导航