SQLite分组
我有一个问题:SQLite分组,sql,sqlite,group-by,Sql,Sqlite,Group By,我有一个问题: select a,count(b) from xyz group by a; 这为我提供了表中每个不同“a”值的出现次数。我的问题是如何查询相同的值,但现在由另一个字段“c”分组 例: 对于人口: (b;c;a) 1;2;test1 2;4;test1 3;4;test1 4;4;test1 5;3;test2 5;3;test2 我想得到: (field 'a';number of occurrences for each value of 'c';total of occ
select a,count(b) from xyz group by a;
这为我提供了表中每个不同“a”值的出现次数。我的问题是如何查询相同的值,但现在由另一个字段“c”分组
例:
对于人口:
(b;c;a)
1;2;test1
2;4;test1
3;4;test1
4;4;test1
5;3;test2
5;3;test2
我想得到:
(field 'a';number of occurrences for each value of 'c';total of occurrences for 'a')
test1;2;4
test2;1;2
如果您的意思是“c”的不同出现次数”,请尝试:
select a, count(distinct c), count(*)
from xyz
group by a;