Subquery

•Let say if you want to find out who earns a salary more than Ozer’s salary. Than you need two queries, one is to find out how much Ozer earns, and second to find who earns more than that amount.

Select last_name, salary
From employees
Where salary >
(Select salary from employees where last_name = 'Ozer');



With this syntax you will know there are 9 persons that earn more than Ozer.


Select last_name, job_id
From employees
Where job_id =
(select job_id from employees where employee_id = 141);



This syntax will show whose job ID is the same as employee 141.




0 comments:

Post a Comment