编写一段SQL语言:非 Marketing 部门,男性未婚数量超过其部门总人数 30% 的部门 列:(部门名称)
select DepartmentName from Data
where DepartmentName!= 'Marketing' and MaritalStatus='S' and Gender='M'
group by DepartmentName
having (COUNT(Name)/COUNT*)>30%
SELECT a.departmentName, a.c, b.d FROM
(select departmentName,COUNT(*) c from employees where DepartmentName!= 'to' group by departmentName) a LEFT JOIN
(select count(*) d,departmentName from employees where maritalStatus='S' and gender='M' group by departmentName) b
ON a.departmentName = b.departmentName
having (b.d/a.c)>0.3