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

SQL Practice Questions Updated

Uploaded by

praveens.ece2022
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)
6 views

SQL Practice Questions Updated

Uploaded by

praveens.ece2022
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/ 3

SQL Practice Questions

1. Employees
Column Data Type Description

EmployeeID INT Primary key

Name VARCHAR Employee name

Department VARCHAR Department name

Salary DECIMAL Salary amount

HireDate DATE Date of hire

2. Departments
Column Data Type Description

DepartmentID INT Primary key

DepartmentName VARCHAR Name of department

Location VARCHAR Department location

Beginner Level (Q1–Q20)


1. Retrieve all records from the Employees table.
2. Get names and salaries of all employees.
3. List all unique departments.
4. Show employee names in alphabetical order.
5. Display the first 3 employees hired.
6. Find employees from the IT department.
7. Get employees with salary more than 60000.
8. Find employees whose name starts with 'A'.
9. Count total number of employees.
10. Find the maximum salary.
11. Retrieve average salary of all employees.
12. List employees hired after Jan 1, 2020.
13. Get employee names and departments.
14. Find employees whose names end with 'a'.
15. List employees with salary between 60000 and 70000.
16. Count employees per department.
17. Show employees not in the Sales department.
18. Rename the Salary column as MonthlyPay.
19. Sort employees by salary in descending order.
20. Find the name and hire date of employees from the HR department.

Intermediate Level (Q21–Q40)


21. Calculate total salary for each department.
22. Get the department with highest average salary.
23. List departments with more than one employee.
24. Show the oldest hire date in each department.
25. Join Employees with Departments to get location info.
26. Show all departments even if no employees are assigned.
27. Count number of employees per location.
28. Show employees hired in 2022.
29. Find employees with the same salary.
30. Find departments with average salary over 65000.
31. List all employees with their department's location.
32. Find total number of employees by department and location.
33. Find departments without any employees.
34. List employees whose department location is Chicago.
35. Retrieve the second highest salary.
36. List employees earning more than the average salary.
37. List department names common to both tables.
38. Find all departments from both tables (UNION).
39. Find employees not assigned to any department listed in Departments.
40. Count employees hired each year.
Advanced Level (Q41–Q50)
41. List employees who joined in the past 1 year.
42. Show top 2 highest salaries per department.
43. List departments with total salary greater than overall average.
44. Find employees who belong to more than one department.
45. Show employee details with NULL if department not found.
46. Find total, average, and max salary in a single query.
47. List employees whose department has more than 1 employee.
48. Find departments with less than 2 employees or no employees.
49. Retrieve the highest paid employee from each department.
50. Simulate INTERSECT to find matching departments in both tables.

You might also like