第一张表:员工
+------------+-----------+----------+-----+--------+--------+-------+
| EmployeeID | FirstName | LastName | Age | Gender | Salary | JobID |
+------------+-----------+----------+-----+--------+--------+-------+
第二张表: JobTitle
+-------+----------+----------------+--------+
| JobID | JobTitle | JobDescription | Status |
+-------+----------+----------------+--------+
编写一个SQL查询来统计所有员工和GROUP BY
年龄和性别。 (输出显示别名)
我已完成以下查询:
SELECT COUNT(EmployeeID) AS Number_Of_Employees
FROM Employee
GROUP BY Age, Gender;
SELECT COUNT(*) AS 'Total_Employees'
FROM Employee
WHERE Gender = 'M' OR Gender= 'F'
GROUP BY Age, Gender;
这是两个查询的结果:
答案 0 :(得分:0)
我想我找到了答案。我最终运行了这个查询,我认为它有效。
SELECT Age, Gender,
COUNT(EmployeeID) AS Total_Employee
FROM Employee
GROUP BY Age, Gender;