Name Salary Department
A 9568 IT
B 7854 IT
C 8564 IT
D 4875 IT
E 5895 HR
F 8858 HR
G 9858 HR
H 11852 FINANCE
I 7582 OPERATION
J 5892 OPERATION
K 12850 FINANCE
L 5265 STORE
M 3582 STORE
N 8520 FINANCE
编写SQL查询以获取薪水高于部门IT和OPERATION工作人员平均薪水的名称
答案 0 :(得分:0)
SET @value = AVERAGE(Salary) FROM YOURTABLE WHERE department in ('OPERATION', 'IT')
SELECT * FROM YOURTABLE WHERE Salary > @value;
我认为这应该有效。用表名替换YOURTABLE。