如何计算分组的行数?

时代s'q

假设我有一个表格,其中包含电子邮件、topic_id 等列。一封邮件可以多次对应一个topic_id。我想根据电子邮件和 topic_id 申请分组。但我无法计算有多少行组合在一起。例子。

email           topic_id     
[email protected]     1
[email protected]     1 
[email protected]     1
[email protected]     2
[email protected]     1
[email protected]     1
[email protected]     1

输出应给出:

    email        topic_id    count   
[email protected]     1            3
[email protected]     2            1
[email protected]     1            3
艾希瓦那

简单的分组和计数?

select email,topic_id, count(*) 
from tablename
group by email,topic_id

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章