後使用字母X這裏是我的查詢SQL子查詢和括號
SELECT deptno,
sum(distinct sal) as total_sal,
sum(bonus) as total_bonus
FROM (
SELECT e.empno,
e.ename,
e.sal,
e.deptno,
e.sal*case when eb.type is null then 0
when eb.type = 1 then .1
when eb.type = 2 then .2
else .3 end as bonus
FROM EMP e left outer join EMP_BONUS eb
on (e.empno = eb.empno)
WHERE e.deptno = 10
) X <----------- if I don't use this I get an error
GROUP BY deptno
如果我省略了X,我得到一個錯誤說「附近關鍵字‘組’語法錯誤。任何人都可以解釋這樣做的目的「X」?
它被稱爲表別名。一些數據庫要求它在'from'子句中用於子查詢。 –