Professional Documents
Culture Documents
Lab Task#04 (29640) (SE 4-1)
Lab Task#04 (29640) (SE 4-1)
1. Display the report of all those employees whose income is less than those who
work in department numbers 50, 20, and 10.
3. The HR department needs a report that displays the last name, department
number, and job ID of all employees whose department location ID is 1700.
where location_id=1700);
4. Display the job number and job title of those employees whose maximum salary is
greater than 'ST_MAN'.
where job_id='ST_MAN');
5. Show a report that displays the employee number, first name, and salary of all
employees who earn more than the average salary. Sort the results according to
salary in ascending order.
order by employee_id;
6. Display all the departments that have a minimum salary greater than that of
department 50.
group by department_id
where department_id=50);
Examples:
1. Which employees salary greater than Jones salary?
SELECT last_name, salary
FROM employees WHERE salary > (SELECT salary FROM employees WHERE
last_name = 'Jones');
2. Display the employees first name ,job id whose job title is the same as that
of employee 177.
Select first_name,job_id
From employees
Where job_id=(select job_id From employees Where employee_id=177);
3. Display all employee records whose job title is the same as that of
employee 141 and whose salary is greater than that of employee 143
SELECT * FROM employees
WHERE job_id = (SELECT job_id FROM employees WHERE employee_id = 141)
AND salary > (SELECT salary FROM employees WHERE employee_id = 143);
4. Operator Example
SELECT employee_id, last_name, job_id, salary
FROM employees
WHERE salary < ANY (SELECT salary FROM employees WHERE job_id =
'IT_PROG')
5. Operator Example
SELECT employee_id, last_name, job_id, salary
FROM employees
WHERE salary < ALL (SELECT salary FROM employees WHERE job_id =
'IT_PROG')
6. Display the employee name, job title and salary of all employees whose
salary is equal to the minimum salary.
SELECT last_name, job_id, salary
FROM employees
WHERE salary = (SELECT MIN(salary) FROM employees);
7. Display all the departments that have a minimum salary greater than that
of department 20.
SELECT department_id, MIN(salary)
FROM Employees
GROUP BY department_id
HAVING MIN (salary)> (SELECT MIN (salary) FROM employees WHERE
department_id=20);