我在SQL分配中遇到问题。
我必须列出我的数据中收入超过$ 3000.00的所有员工。
这些是我的表
EMPLOYEE Table
EMP_NUM EMP_NAME JOB_CLASS
101 John G. News Database Designer
102 David H. Senior Systems Analyst
103 June E. Arbough Electrical Engineer
104 Anne K. Ramoras Systems Analyst
105 Alice K. Johnson Database Designer
106 William Smithfield Programmer
107 Maria D. Alonzo Programmer
108 Ralph B. Washington Systems Analyst
111 Geoff B. Wabash Clerical Support
112 Darlene M. Smithson DSS Analyst
113 Delbert K. Joenbrood Applications Designer
114 Annelise Jones Applications Designer
115 Travis B. Bawangi Systems Analyst
118 James J. Frommer General Support
ASSIGN Table
EMP_NUM PROJ_NUM HOURS
101 15 19.4
102 15 23.8
103 15 23.8
105 15 35.7
106 15 12.6
104 18 32.4
112 18 44
114 18 24.6
118 18 45.3
104 22 48.4
105 22 64.7
106 22 12.8
111 22 22
113 22 23.6
101 25 56.3
107 25 24.6
108 25 23.6
112 25 41.4
114 25 33.1
115 25 45.8
118 25 30.5
JOB Table
JOB_CLASS CHG_HOUR
Applications Designer 48.1
Clerical Support 26.87
Database Designer 105
DSS Analyst 45.95
Electrical Engineer 84.5
General Support 18.36
Programmer 35.75
Systems Analyst 96.75
对于列出所有从事多个项目的员工的上一个问题,我确实喜欢这个
select COUNT (a.PROJ_NUM), e.EMP_NAME
from EMPLOYEE e, ASSIGN a
where e.EMP_NUM = a.EMP_NUM
Having COUNT (a.PROJ_NUM) >= 2
group by e.EMP_NAME;
这段代码给了我想要的东西
我现在遇到的问题是获得超过3000.00的名单
所以我确实喜欢这个
select COUNT (a.HOURS * j.CHG_OUR), e.EMP_NAME
from EMPLOYEE e, ASSIGN a. JOB j
where j.JOB_CLASS = e.JOB_CLASS
and e.EMP_NUM = a.EMP_NUM
Having COUNT (a.HOURS * j.CHG_OUR) >= 3000
group by e.EMP_NAME;
但这一次,这段代码没有给我我想要的东西
它只打印出这样的错误信息
ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Error at Line: 60 Column: 26
如果你知道如何解决它,请回答我
谢谢
答案 0 :(得分:1)
这样的事情:
select SUM (a.HOURS * j.CHG_OUR), e.EMP_NAME
from EMPLOYEE e, ASSIGN a. JOB j
where j.JOB_CLASS = e.JOB_CLASS
and e.EMP_NUM = a.EMP_NUM
group by e.EMP_NAME
Having SUM (a.HOURS * j.CHG_OUR) >= 3000;
答案 1 :(得分:0)
我认为你可以这样做:
select SUM(a.HOURS * j.CHG_OUR), e.EMP_NAME
from EMPLOYEE e, ASSIGN a, JOB j
where j.JOB_CLASS = e.JOB_CLASS
and e.EMP_NUM = a.EMP_NUM
group by e.EMP_NAME
Having sum(a.HOURS * j.CHG_OUR) >= 3000;
答案 2 :(得分:0)
这个怎么样:
select COUNT (a.HOURS * j.CHG_OUR), e.EMP_NAME
from EMPLOYEE e, ASSIGN a. JOB j
where j.JOB_CLASS = e.JOB_CLASS
and e.EMP_NUM = a.EMP_NUM
group by e.EMP_NAME;
Having COUNT ((a.HOURS * j.CHG_OUR) >= 3000)
我在你的计数周围加了一套额外的parens。