SQL Assignment
SQL Assignment
Consider the tables given below and answer the questions that follow:
Table: Employee
Table: Department
Dept DName MinSal MaxSal HOD
10 Sales 25000 32000 1
20 Finance 30000 50000 5
30 Admin 25000 40000 7
Create Table
1.Create the table Employee.
2.Create the table Department.
Insert data in a table
3.Insert data in the table Employee
4.Insert data in the table Department.
Simple Select
5.Display the Salary, Zone, and Grade of all the employees.
6.Display the name of all the employees along with their annual salaries.
The new column should be given the name “Annual Salary”.
Conditional Select using Where Clause
7.Display the details of all the employees who are below 30 years of age.
Using DISTINCT Clause
8.Display the names of various zones from the table Employee. A zone name should
appear only once.
Using Logical Operators (NOT, AND, OR)
9.Display the details of all the employees who are getting a salary of more than 35000
in the department 30.
10.Display the names and salaries of all the employees who are not working in
department 20.
11.Display the details of all the employees whose salary is between 32000 and 38000.
Using IN Operator
12.Display the names of all the employees who are working in department 20 or 30.
(Using IN operator)
Using BETWEEN Operator
13.Display the details of all the employees whose salary is between 32000 and 38000.
14.Display the details of all the employees whose grade is between ‘A’ and ‘C’.
Using LIKE Operator
15.Display the name, salary, and age of all the employees whose names start with ‘M’.
16.Display the name, salary, and age of all the employees whose names contain ‘a’ in
the descending order of their names.
17.Display the details of all the employees whose names contain ‘a’ as the second
character.
Using Aggregate functions
18.Display the highest and the lowest salaries being paid in department 10.
19.Display the number of employees working in department 10.
Using ORDER BY clause
20.Display the name and salary of all the employees in the ascending order of their
salaries.
Using GROUP BY clause
21.Display the total number of employees in each department.
22.Display the highest salary, lowest salary, and average salary of each zone.
Using UPDATE, DELETE, ALTER TABLE
23.Put the grade B for all those whose grade is NULL.
24.Increase the salary of all the employees above 30 years of age by 10%.
25.Delete the records of all the employees whose grade is C and salary is below 30000.
26.Add another column HireDate of type Date in the Employee table.
JOIN of two tables
27.Display the name, salary of all the employees who work in Sales department.
28.Display the Name and Department Name of all the employees.
29.Display the names of all the employees whose salary is out of the specified range
for the corresponding department.
30.Display the name of the department and the name of the corresponding HOD for
all the departments.