1.

Write queries (a) to (d) based on the tables EMPLOYEE and DEPARTMENT given below:Table: EMPLOYEETable: DEPARTMENTDEPTIDDEPTNAMEFLOORNOD001Personal4D002Admin10D003Production1D004Sales3(a) To display the average salary of all employees, department wise. (b) To display name and respective department name of each employee whose salary is more than 50000.(c) To display the names of employees whose salary is not known, in alphabetical order. (d) To display DEPTID from the table EMPLOYEE without repetition.

Answer»

(a) SELECT AVG(SALARY)

FROM EMPLOYEE 

GROUP BY DEPTID;

(b) SELECT NAME, DEPTNAME 

FROM EMPLOYEE, DEPARTMENT 

WHERE

EMPLOYEE.DEPTID= 

    DEPARTMENT.DEPTID 

 AND SALARY>50000;

(c) SELECT NAME FROM EMPLOYEE 

WHERE SALARY IS NULL 

ORDER BY NAME;

(d) SELECT DISTINCT DEPTID 

FROM EMPLOYEE;



Discussion

No Comment Found

Related InterviewSolutions