SQL COOKBOOK 练习3.9在SQL SERVER下的错误

书上给出的DB2,ORACLE,SQLSERVER的解决方案,在SQLSERVER中不能使用。

只能使用中间那个通用的解决办法:
Select e.DEPTNO,sum(e.SAL*(case when eb.TYPE=1 then .1 when eb.TYPE=2 then.2 when eb.TYPE=3 then .3 end)) as total_bonus,total_sal
from EMP e,EMP_BONUS eb,
			(Select DEPTNO,SUM(sal) as total_sal
			from EMP
			where DEPTNO=10
			group by DEPTNO) d
where e.EMPNO = eb.EMPNO
and	  e.DEPTNO = d.DEPTNO
group by e.DEPTNO,total_sal

你可能感兴趣的:(oracle,sql,SQL Server,db2)