我如何做一个计数不同在sqlite? [英] How can I do a count distinct in sqlite?
本文介绍了我如何做一个计数不同在sqlite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表格:
ref,type
1,red
2,red
3,green
4,blue
5,black
6,black
b $ b
我想要sqlite查询的结果是:
red,2
green, 1
blue,1
black,2
我认为最难的事做是找到一个问题,以匹配我的问题?
解决方案 / div>
一个快速的google给了我: http://www.mail -archive.com/sqlite-users@sqlite.org/msg38339.html
选择类型,计数)from table group by type;
I have a table:
ref,type
1,red
2,red
3,green
4,blue
5,black
6,black
I want the result of a sqlite query to be:
red,2
green,1
blue,1
black,2
I think the hardest thing to do is find a question to match my problem? Then I am sure the answer is around the corner....
:)
解决方案
A quick google gave me this: http://www.mail-archive.com/sqlite-users@sqlite.org/msg38339.html
select type, count(type) from table group by type;
这篇关于我如何做一个计数不同在sqlite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文