小编Chu*_*ydb的帖子

Postgresql一个表的多个计数

从我表中的两列开始,我想获得这些列中值的统一计数.例如,两列是:

表:报告

|   type        |   place   |  
 ----------------------------------------- 
|   one         |   home    |  
|   two         |   school  |  
|   three       |   work    |  
|   four        |   cafe    |  
|   five        |   friends |  
|   six         |   mall    |  
|   one         |   work    |  
|   one         |   work    |  
|   three       |   work    |  
|   two         |   cafe    |  
|   five        |   cafe    |  
|   one         |   home    |  
Run Code Online (Sandbox Code Playgroud)

如果我这样做:SELECT类型,按类型从报告组计数(*)

我明白了:

|   type        |   count   |  
-----------------------------  
|   one         |   4 …
Run Code Online (Sandbox Code Playgroud)

sql postgresql group-by count

23
推荐指数
4
解决办法
2万
查看次数

标签 统计

count ×1

group-by ×1

postgresql ×1

sql ×1