Empl (E_no, E_name, No)

Q. Consider the following database with primary keys underlined-
Empl (E_no, E_name, No)
Dept (D_no, D_name)
Emp_sal(E_no, Basic, DA, HRA, Tot-sal)
Represent the following queries in SQL-
(i) Get the names of all employees whose total salary is more than Rs. 10000.
(ii) Get Dept. names of employees who earn more than Rs. 50000 (Tot-salary).
(iii) Get the names of employees whose HRA is nil.

Solution:
(i) select E_name form Empl where E_no IN
(select E_no from Empl_sal where Tot_sal >10000)


(ii) select D_name form Dept where D_no in
(select No from Empl where E_no IN
(select E_no from Empl_sal where Tot_sal > 50000.


(iii) select E_name form Empl where E_no IN

(select E_no from Empl_sal where HRA = 0.00).

More topics from DBMS to read:

DATABASE MANAGEMENT SYSTEM

EasyExamNotes.com covered following topics in DBMS.
A list of Video lectures

Post a Comment

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.