Multi Row Function SQL
Multi Row Function SQL
Multi Row Function SQL
1. Write a query to fetch the EmpFname from the Emp table in upper case and use the ALIAS name
as Empname?
select LOWER(Ename) as Empname
from emp;
ANS:
EMPNAME
----------
smith
allen
ward
jones
martin
blake
clark
scott
king
turner
adams
james
ford
miller
FUNCTIONS
Multi row functions SQL queries
1. WAQTD minimum salary in employee’s table
select min(sal)
from emp;
ANS: MIN(SAL)
----------
800
select sum(sal)
from emp;
ANS: SUM(SAL)
----------
29025
select avg(sal)
from emp;
ANS: AVG(SAL)
----------
2073.21429
select max(sal)
from emp
where deptno=10;
ANS: MAX(SAL)
----------
5000
select count(*)
from emp;
ANS: COUNT(*)
----------
14
select count(*)
from emp
where sal<2000 and deptno = 10;
ANS: COUNT(*)
----------
1
7. WAQTD total salary needed to pay the employees working as clerk
select sum(sal)
from emp
where job in 'CLERK';
ANS: SUM(SAL)
----------
4150
select count(*)
from emp
where ename like ‘A%’;
ANS: COUNT(*)
----------
ANS: COUNT(*)
----------
10. WAQTD total salary needed to pay employees hired in the month of Feb
select sum(sal)
from emp
where hiredate like '%FEB%';
ANS: SUM(SAL)
----------
2850
11. WAQTD number of employees reporting to 7839(MGR)
select count(*)
from emp
where MGR in 7839;
Ans: COUNT(*)
----------
select count(*)
from emp
where comm is not null and deptno in 30;
ANS: COUNT(*)
----------
13. WAQTD average salary, total salary, number of employees and maximum salary given to the
employees working as president
ANS: COUNT(*)
----------
7
15. WAQTD number of employees and total salary needed to pay the employees who have 2
consecutive L's in their name
select count(*)
from emp
where ename like '%LL%';
ANS: COUNT(*)
----------
ANS: COUNT(DISTINCTDEPTNO)
---------------------