我有下面的SQL查詢的問題:嵌套SQL查詢
SELECT job
FROM (SELECT job, COUNT(*) AS cnt
FROM Employee
GROUP BY job)
WHERE cnt=1
至於結果它應該只顯示了CNT(崗位數)等於1
當我上面的測試選擇查詢所有作業小提琴,我得到以下錯誤:
Incorrect syntax near the keyword 'WHERE'.
SQLFiddle:http://sqlfiddle.com/#!6/d812a/7
http://sqlfiddle.com/#!6/d812a/15 – Strawberry
Baker和Gardener的預期結果是什麼? – Loufylouf
您也可以使用HAVING,這將使外部查詢冗餘 – Strawberry