Query for 4th CIA


CIA 4th of DBMS

  1. Using group functions, retrieve suitable results by using HAVING, GROUP BY and ORDER BY clauses
    1. Find the age of highest paid employee who is at least 30 years old for each department with at least two such employees.

>select max(sal),deptno as salary from Employee where age>30 group by dept having count(*)>2;

  1. Find those departments for which the average age of employee is the minimum over all departments.
    • Don’t know
  2. Find the sum of salary of all the employees in a each department having department number greater than 10.
    • I have done it with age greater than 30( department nu is in varchar so)
    • Select sum(sal) as Sumsal,deptno from Employee where age>30 group by deptno;