0% found this document useful (0 votes)
17 views

SQL 4

Uploaded by

aanchal.singhal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

SQL 4

Uploaded by

aanchal.singhal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

SQL - 4

1. A table Employee is given as follows:

Empno EmpName DOB Dept Salary


101 Arun 17-05-1977 HR 20000
103 Varun 24-01-1996 FIN 30000
104 Shreeya 20-12-1996 HR
105 Sriman 07-07-1998 MKT 45000
106 Vijeta 25-09-1996 FIN 27000
109 Arjun HR 34000
2. Identify the attribute best suitable to be the Primary key. Justify your answer.
3. Write the degree and cardinality of the table.
4. Find the output of the following queries:
a. Select Empname from Employee where DOB is NULL;
b. Select max(dob) , min(dob) from employee;
c. Select sum(salary),dept from employee group by Dept;
d. Select count(distinct dept) from employee;
e. Select distinct dept from employee;
f. Select count(salary) from employee;
g. Select avg(salary),dept from employee group by dept having salary >25000;
h. Select empname, salary from employee where empname like “%n”;
i. Select sum(salary) where empno between 104 and 106;
5. Another table City is given with following data:

Dept City
HR Delhi
FIN Mumbai
MKT Kolkata
i. What will be the degree and cardinality of the tables Employee and City?
ii. Find the output of the following query
a. Select A. Dept, empNAme,City from Employee A, City B where
A.Dept=B.Dept;
Write queries based on the given table Employee
1. To display all data of HR department.
2. To display names of employees whose salary is >=25000 and <=35000
3. To display the data of employees whose name contains “E”
4. To change the salary to 28000 for the employees whose salary is null
5. To increase salary of employees by 2000
6. To display name of all employees of HR dept whose empno >=102
7. To add a new column Bonus of numeric type
8. To assign 10% of salary as Bonus
9. To display name, salary of all employees of HR or MKT depts.
10. To display all data in ascending order of Salary.
-*-

You might also like