在我的sql中,我有如下所示的表。在那个表中,我有一个topicID,它不是一个主键,只是为了说明这一点。我正在努力编写一个脚本,它可以在表中给出相同的topicID数。
topicID | description | date |
| 1 | xyz | 2018-11-11 |
| 1 | xyz | 2018-11-11 |
| 2 | xyz | 2018-11-11 |
| 1 | xyz | 2018-11-11 |
| 3 | xyz | 2018-11-11 |
| 3 | xyz | 2018-11-11 |
| 2 | xyz | 2018-11-11 |
| 1 | xyz | 2018-11-11 | 例如:
topic Id numberOfTime
1 4
2 2
3 3发布于 2018-03-23 03:26:35
您需要的是按组表达式。尝试以下几点,
select topicId as 'Topic Id' ,count(*) as 'Number of times' from my_table group by topicIdhttps://stackoverflow.com/questions/49441888
复制相似问题