0% found this document useful (0 votes)
5 views2 pages

Task

The document outlines a series of SQL tasks related to managing employee, department, and project data. It includes creating tables, inserting records, updating and deleting data, and performing various queries to retrieve specific information. The tasks cover a range of SQL operations such as joins, subqueries, and aggregate functions.

Uploaded by

shangaric12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Task

The document outlines a series of SQL tasks related to managing employee, department, and project data. It includes creating tables, inserting records, updating and deleting data, and performing various queries to retrieve specific information. The tasks cover a range of SQL operations such as joins, subqueries, and aggregate functions.

Uploaded by

shangaric12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

DAY 1 Task:

1. Write a SQL query to create a table named "Employees" with columns: "EmployeeID"
(integer, primary key), "FirstName" (text), "LastName" (text), "Salary" (decimal), and
"DepartmentID" (integer).

2. Write a SQL query to insert a new record into the "Employees" table with values:
EmployeeID = 401, FirstName = 'Bob', LastName = 'Taylor', Salary = 75000,
DepartmentID = 10.

3. Write a SQL query to create a table named "Departments" with columns:


"DepartmentID" (integer, primary key), "DepartmentName" (text), and "Location"
(text).

4. Write a SQL query to insert multiple rows into the "Departments" table in a single
query.

5. Write a SQL query to create a table "Projects" with fields: "ProjectID" (integer),
"ProjectName" (text), and "Budget" (decimal), ensuring "ProjectID" is unique.

6. Write a SQL query to delete all employees from the "Employees" table who earn less
than 40000.

7. Write a SQL query to update the "Salary" of employees in DepartmentID 5 by


increasing it by 10%.

8. Write a SQL query to remove the "Departments" table from the database.

9. Write a SQL query to change the "Location" of the "IT" department to 'Building B'.

10. Write a SQL query to delete records from the "Projects" table where the Budget is
NULL or 0.

11. Write a SQL query to select all columns from "Employees" where the last name starts
with 'S' and ends with 'n'.

12. Write a SQL query to select "FirstName", "LastName", and "Salary" from "Employees"
and sort by "Salary" in ascending order.

13. Write a SQL query to retrieve employees whose salary is between 60000 and 90000.

14. Write a SQL query to display the top 3 highest-paid employees.

15. Write a SQL query to select all employees who do not belong to any department (i.e.,
DepartmentID is NULL).

16. Write a SQL query to list all distinct department locations.


17. Write a SQL query to count how many employees are in each department.

18. Write a SQL query to find the average salary of employees grouped by DepartmentID.

19. Write a SQL query to find the maximum and minimum salary in the "Employees" table.

20. Write a SQL query to find departments having more than 5 employees using GROUP
BY and HAVING.

21. Write a SQL query to display the full names of employees along with their department
names using a JOIN.

22. Write a SQL query to list the names of employees who are assigned to projects with
budgets over 1,000,000.

23. Write a SQL query using a subquery to find employees who earn more than the
average salary of all employees.

24. Write a SQL query using a JOIN to find departments that have no employees assigned.

25. Write a SQL query to list all employees along with project details using LEFT JOIN
(even if the employee isn’t assigned to a project).

26. Write a SQL query to create a new view named "HighSalaryEmployees" that shows all
employees with salary greater than 100000.

27. Write a SQL query to list the second highest salary from the "Employees" table.

28. Write a SQL query to add a new column named "Bonus" (decimal) to the "Employees"
table and update it as 10% of the Salary.

29. Write a SQL query to select the department with the highest average salary.

30. Write a SQL query to find employees whose names contain exactly 5 letters and end
with 'n'.

You might also like