在线求sql语句 急
员工表:WS_Employee
ID NAME
1 a君
2 b君
3 c君
4 d君
5 e君
6 f君
计件工资:WS_jjgz
ID 员工ID price
1 1 125
2 2 122
3 3 111
4 1 212
5 1 111
6 2 121
计时工资:WS_jsgz
ID 员工ID price
1 1 125
2 2 122
3 3 111
4 1 212
5 1 111
6 2 121
我想显示效果还是那个
ID NAME 计件总工资 计时总工资 总工资
1 a君 448 448 896
2 b君 243 243 486
3 c君 111 111 222
4 d君 0 0 0
5 e君 0 0 0
6 f君 0 0 0
应该怎么写sql语句?
------解决方案--------------------select id,name,sum(WS_jjgz.price) as 计件总工资,sum(WS_jsgz.price) as 计时总工资,sum(sum(WS_jjgz.price)+sum(WS_jsgz.price)) as 总工资
from 数据表
where WS_Employee.id=WS_jjgz.员工id and WS_Employee.id=WS_jsgz.员工id
没测试,不知道行不行
------解决方案--------------------CREATE TABLE WS_Employee
(
ID INT,
NAME VARCHAR(10)
)
INSERT INTO WS_Employee
SELECT 1, 'a君 ' UNION ALL
SELECT 2, 'b君 ' UNION ALL
SELECT 3, 'c君 ' UNION ALL
SELE