gpt4 book ai didi

mysql - 统计各部门用户

转载 作者:行者123 更新时间:2023-11-29 04:40:15 25 4
gpt4 key购买 nike

我有一个具有以下布局的表格:

+----+-----------+-------------+| id | name      | department  |+----+-----------+-------------+|   1| John      | Finance     |+----+-----------+-------------+|   2| Bob       | Optics      |+----+-----------+-------------+|   3| Jill      | Finance     |+----+-----------+-------------+|   4| Jake      | Finance     |+----+-----------+-------------+|   5| Mike      | Support     |+----+-----------+-------------+

我想得到每个部门所有人员的总和:

+-----------+-------------+| people    | department  |+-----------+-------------+|          3| Finance     |+-----------+-------------+|          1| Optics      |+-----------+-------------+|          1| Support     |+-----------+-------------+

我在构造正确的查询时遇到问题

最佳答案

使用 COUNT

SELECT COUNT(name),department FROM table GROUP BY department

关于mysql - 统计各部门用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30614883/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com