我不明白我得到的错误!
我的问题是,我必须显示员工的姓名和他们所从事的会议数量。如果员工没有直接在任何会议上工作,则必须为该员工显示0。与此查询关联的表是:
Employee_C表:
EID NAME SALARY MID
--- -------------------- -----
e01 Wilson 53000
e02 Smith 48000 e01
e03 Jones 38000 e01
e04 Loftus 41000
e05 Fox 54000 e04
e06 Smith 45000 e04
e07 Green 48000
e08 Fox 49000 e04
e09 Wolf 41000 e04
e10 Wang 32000 e01
e11 Phillips 33000 e07
e12 Liu 27000 e07
Deals_C表:
EID CONFID
--- ------
e02 c00001
e03 c00001
e05 c00001
e06 c00001
e03 c00002
e08 c00002
e09 c00002
e10 c00002
e03 c00003
e05 c00003
e06 c00004
e08 c00005
e09 c00005
e10 c00005
e06 c00005
e11 c00006
e12 c00006
e05 c00007
e06 c00007
e08 c00007
e09 c00008
e10 c00008
e11 c00008
e02 c00009
e12 c00009
e10 c00010
e02 c00011
e03 c00011
e05 c00011
e12 c00012
e06 c00012
我拥有的sql语句是
select E.Name, D.ConfID as "Number of Conferences"
from Employee_C E left outer join Deals_C D on E.eid = D.eid group by E.eid;
错误:
选择E.Name,D.ConfID作为“会议数” * 第1行出错: ORA-00979:不是GROUP BY表达式
请帮忙! 谢谢
答案 0 :(得分:1)
您缺少一个聚合函数,并且您在不在GROUP BY
列表中的列上使用SELECT
。您需要GROUP BY E.Name
,因为该列位于选择中:
select E.Name, count(D.ConfID) as "Number of Conferences"
from Employee_C E
left outer join Deals_C D
on E.eid = D.eid
group by E.Name;