Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 在SQL中查找员工超过10人的门店_Mysql_Sql - Fatal编程技术网

Mysql 在SQL中查找员工超过10人的门店

Mysql 在SQL中查找员工超过10人的门店,mysql,sql,Mysql,Sql,假设我有一个表stores\u employees,它有两列: store_id, employee_id 我怎样才能找到一家员工超过10人的商店?最好的方法是什么?您将在HAVING子句和groupby store\u id select store_id from stores_employees group by store_id having count(employee_id) > 10 看 如果要包括员工总数,则可以使用: select store_id, count(e

假设我有一个表
stores\u employees
,它有两列:

store_id, employee_id

我怎样才能找到一家员工超过10人的商店?最好的方法是什么?

您将在
HAVING
子句和
groupby store\u id

select store_id
from stores_employees 
group by store_id
having count(employee_id) > 10

如果要包括员工总数,则可以使用:

select store_id, count(employee_id) TotalEmployees
from stores_employees 
group by store_id
having count(employee_id) > 10

从逻辑上考虑这个问题,您需要从stores\u emloyes表中统计store\u id和employee\u id的实例,其中count大于10

我发现这是学习mysql最有效的方法,而不是从网站上复制

您可能使用的关键字:

SELECT
FROM
ORDER BY
BETWEEN

如果这个问题更难,你就不会有答案,但人们会问你像约翰一样尝试了什么,但简单的分数会让你快速得到答案。在将来,试着发布你尝试过的东西,或者至少读过关于它的文章。同意我的@Luis,-1。
SELECT
FROM
ORDER BY
BETWEEN