|
本帖最后由 asdf2110 于 2013-5-27 16:22 编辑
- select c1, sum(c) from
- (select c1, count(*) as c from st group by c1
- union all
- select c2 as c1, count(*) as c from st group by c2
- union all
- select c3 as c1, count(*) as c from st group by c3
- ) t
- group by c1;
复制代码 还是
- select c1,c2,c3,count(*) from st group by grouping sets(c1, c2,c3);
复制代码 前一个效率不高,不知道有什么其他办法
|
|