【发布时间】:2012-01-26 05:28:28
【问题描述】:
我有两张桌子,
department
———-
deptid (type: INT)
deptname (type: TEXT)
hours (type: INT)
active (type: BIT)
employee
——–
empid (type: INT)
empname (type: TEXT)
deptid (type: INT)
designation (type: TEXT)
salary (type: INT)
现在如何在不使用返回列 empname 和 deptname 的子查询的情况下进行查询,该列属于员工人数为 4 或更多的部门的员工。记录应按 empname 的字母顺序返回。
【问题讨论】:
-
我做了这样的解决方案:select e.empname , d.deptname, d.
deptidfrom employee e inner join department d where e.deptid= d.deptidand e .deptidin (select deptid from employee group by deptid have (count(deptid)) >= 4) order by e.empname;但我想要它没有子查询。