Professional Documents
Culture Documents
Urk17bi019 PDF
Urk17bi019 PDF
Aim :
To execute commands making use of SUB QUERIES on table and retrieving outputs.
Description :
• The subquery (inner query) executes once before the main query.
• The result of the subquery is used by the main query (outer query).
-Use single-row operators with single-row subqueries and use multiple-row operators with
multiple-row subqueries.
QUES3: List the employees who are earning less than the average salary of accounting department
QUES4: List the names of the employees who earns more than some employees in sales
QUERY: select fname,dept,salary from EXP4_19 where salary >
(
select avg(salary) from EXP4_19 where dept='sales'
)
and dept='sales';
OUTPUT:
QUES5: List the name of salesman who earns more than all employees of job clerk
QUERY: select fname,dept,salary from EXP4_19 where salary =
(
select max(salary) from EXP4_19 where dept='clerk'
)
order by fname ;
OUTPUT:
QUES6: List the name, job, salary of employees who earn more than the average salary of all departments
QUES10: Write a query to display the employee name and hire date for all employees in the same department as
blake exclude blake.
QUERY: select fname,dept,hiredate from EXP4_19 where dept = all
(
select dept from EXP4_19 where fname = 'don'
)
and fname <> 'don' ;
OUTPUT:
QUES11: Write a query to display the employee member and name for all employees who
work in a department with any employee whose name contains t.
QUERY: select fname as "Name",jobid as "Emp #",dept from EXP4_19 where dept in
(
select dept from EXP4_19 where fname like '%t%'
)
order by dept ;
OUTPUT:
QUES12: Find avg salary of employees of those department where average salary >5000
QUERY: select fname,jobid,dept,avg(salary) from EXP4_19 where salary > any
(
select avg(salary) from EXP4_19 group by dept having avg(salary) > 5000
)
group by fname,jobid,dept having avg(salary) > 5000 order by dept ;
OUTPUT:
QUES13: Find the sum of salary of employees of those department where salary >5000.
Result:
The SUB QUERIES were successfully implemented and the required queries were performed on the
Database.