[SQL ] 请教query题目

楼主: AmigoSafin   2019-07-31 05:02:57
(针对 SQL 语言的问题,用这个标题。请用 Ctrl+Y 砍掉这行)
数据库名称: Oracle
数据库版本:18c
内容/问题描述:
大家好 请教一题query如何解?谢谢!
Display a RANKING of the managers based on how many employees report to
them- note that a rank of 1 means that the manager manages the greatest
number of employees.
我用的是:
select m.first_name, m.last_name, COUNT(*) as NUM_EMPLOYEE from
RITDB_employee e, RANK() over (partition by (select COUNT(*) as NUM_EMPLOYEE
from RITDB_employee e INNER JOIN RITDB_manager m ON e.manager=m.employee_id
group by m.first_name, m.last_name) AS RANK) WHERE rownum=1)
错误为wondows function are not allowed here
Thanks a lot!!
作者: retsamsu   2019-07-31 17:11:00
put analytic functions inside aggregate functions
作者: CSBS (地上波)   2019-08-02 01:29:00
rank over () 要放在select

Links booklink

Contact Us: admin [ a t ] ucptt.com