Altsorgunun SELECT kisminda birden fazla sutun yer aliyorsa bunlara cok sutunlu alt sorgular denir. Cok sutunlu alt sorugular genelde sutunlarin karsilastirilmasinda kullanilir yada UPDATE cumlelerinde kullanilir.
Asagidaki sorgudaki her departmende en yuksek maasi alan employee listelenmistir..
WHERE (department_id, salary) IN
(SELECT department_id, max(salary)
FROM employees GROUP BY department_id)
ORDER BY salary DESC
FULLNAME SALARY DEPARTMENT_ID
---------------------------------------------- ---------------------- ----------------------
Steven King 31944 90
John Russell 18634 80
Nancy Greenberg 15982.65 100
Shelley Higgins 15982.65 110
Den Raphaely 14641 30
Hermann Baer 13310 70
Alexander Hunold 11979 60
Adam Fripp 10914.2 50
Susan Mavris 8651.5 40
Pat Fay 7986 20
Jennifer Whalen 5856.4 10
11 rows selected
Hiç yorum yok:
Yorum Gönder