Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个表父子表,例如员工表和部门表。我想显示部门名称,按它们在 Employee 表中出现的次数排序,应该首先列出出现次数最多的部门名称。请告诉我解决方案紧急,SQL 语句应该由 SqlCE 支持
提前致谢....
SELECT dept.Name, COUNT(emp.id) as timesOccurring FROM departments dept INNER JOIN employees emp ON emp.dept_id = dept.id GROUP BY dept.Name ORDER BY timesOccurring
那应该这样做。