[英]What wrong with this SQL Query
I need to find what bad with this SQL: 我需要找出此SQL有什么不好的地方:
SELECT DepartmentName, COUNT(*)
FROM employee,department
WHERE employee.DepartmentID = department.DepartmentID
GROUP BY DepartmentName
WHERE COUNT(*)>1
I think the problem in COUNT(*)
beacause it return the count of all rows. 我认为
COUNT(*)
的问题是因为它返回所有行的计数。 So how I think the property sql will be without where statement. 因此,我认为没有where语句的sql属性将如何。 Help me I not good in SQL.
帮帮我,我不太擅长SQL。
SELECT DepartmentName, COUNT(*) AS count
FROM employee,department
WHERE employee.DepartmentID = department.DepartmentID
GROUP BY DepartmentName
HAVING count>1;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.