我想選擇誰已經比平均總時間,任何人都已經工作,一個陣營的Oracle SQL子查詢
表是人與計劃工作較少的人
這是我到目前爲止有:
SELECT fname AS "First Name", lname AS "Last Name",
SUM((end_time - start_time) * 24)
FROM person JOIN schedule USING (person_ID)
GROUP BY fname
HAVING SUM((end_time - start_time) * 24) < (
SELECT AVG(SUM((end_time - start_time) * 24)) FROM schedule);`
人有FNAME,LNAME和PERSON_ID 時間表sched_id,s_date,START_TIME,END_TIME和PERSON_ID
謝謝!
收到此錯誤:
Error starting at line 18 in command:
SELECT fname AS "First Name", lname AS "Last Name",
SUM((end_time - start_time) * 24)
FROM person JOIN schedule USING (person_ID)
GROUP BY fname
HAVING SUM((end_time - start_time) * 24) < (
SELECT AVG(SUM((end_time - start_time) * 24)) FROM schedule)
Error at Command Line:18 Column:31
Error report:
SQL Error: ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action:
您必須將select中的所有非聚合列包含在group by子句中。 – OldProgrammer