Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQLite分组_Sql_Sqlite_Group By - Fatal编程技术网

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;