[SQL ] 請教query題目

看板Database (資料庫)作者時間5年前 (2019/07/31 05:03), 編輯推噓1(101)
留言2則, 2人參與, 5年前最新討論串1/1
(針對 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!! -- -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 129.21.68.100 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Database/M.1564520580.A.FF6.html

07/31 17:11, 5年前 , 1F
put analytic functions inside aggregate functions
07/31 17:11, 1F

08/02 01:29, 5年前 , 2F
rank over () 要放在select
08/02 01:29, 2F
文章代碼(AID): #1TGB24_s (Database)
文章代碼(AID): #1TGB24_s (Database)