Q. An organization ABC maintains a database EMP-DEPENDENT to record the following details about its employees and their dependents.


EMPLOYEE(AadhaarNo, Name, Address, Department, EmpID)
DEPENDENT(EmpID, DependentName, Relationship)

Use the EMP-DEPENDENT database to answer the following SQL queries:


a) Find the names of employees with their dependent names.

b) Find employee details working in a department, say, ‘PRODUCTION’.

c) Find employee names having no dependent

d) Find names of employees working in a department, say, ‘SALES’ and having exactly two dependents.


Answer :-

a = Select Name , DependentName from EMPLOYEE , DEPENDENT where EMPLOYEE. EmpID  = DEPENDENT. EmpID ;

b = Select * from EMPLOYEE , DEPENDENT where EMPLOYEE. EmpID  = DEPENDENT. EmpID and DependentName = “Production” ;

c = Select * from EMPLOYEE , DEPENDENT where EMPLOYEE. EmpID  = DEPENDENT. EmpID and DependentName is null;

d = Select * from EMPLOYEE , DEPENDENT where EMPLOYEE. EmpID  = DEPENDENT. EmpID and DependentName = “Sales” and  Relationship = 2 ;

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post