SQL Topics
SQL Exercises Beginner
title: SQL Exercises Beginner
Congratulations! 🎉
You have completed:
SQL Theory
SQL Interview Questions
SQL Output QuestionsNow it's time for:
Hands-On PracticeBecause SQL is a skill that improves through:
Practice
Practice
PracticeThis section contains beginner-level exercises designed to strengthen your SQL fundamentals.
Sample Database
Assume the following table:
Employees
| EmployeeID | EmployeeName | Department | Salary |
|---|---|---|---|
| 1 | Rahul | HR | 50000 |
| 2 | Priya | IT | 70000 |
| 3 | Amit | HR | 60000 |
| 4 | Neha | Finance | 80000 |
| 5 | Raj | IT | 65000 |
Exercise 1
Display All Employees
Task
Retrieve all records.
Expected Query
SELECT *
FROM Employees;Exercise 2
Display Employee Names Only
Task
Show only names.
Expected Query
SELECT EmployeeName
FROM Employees;Exercise 3
Display Employees From IT Department
Expected Query
SELECT *
FROM Employees
WHERE Department = 'IT';Exercise 4
Display Employees With Salary Greater Than 60000
Expected Query
SELECT *
FROM Employees
WHERE Salary > 60000;Exercise 5
Display Employees With Salary Less Than 70000
Expected Query
SELECT *
FROM Employees
WHERE Salary < 70000;Exercise 6
Display Employees Ordered By Salary Ascending
Expected Query
SELECT *
FROM Employees
ORDER BY Salary ASC;Exercise 7
Display Employees Ordered By Salary Descending
Expected Query
SELECT *
FROM Employees
ORDER BY Salary DESC;Exercise 8
Find Highest Salary
Expected Query
SELECT MAX(Salary)
FROM Employees;Exercise 9
Find Lowest Salary
Expected Query
SELECT MIN(Salary)
FROM Employees;Exercise 10
Find Total Salary
Expected Query
SELECT SUM(Salary)
FROM Employees;Exercise 11
Find Average Salary
Expected Query
SELECT AVG(Salary)
FROM Employees;Exercise 12
Count Employees
Expected Query
SELECT COUNT(*)
FROM Employees;Exercise 13
Find Employees In HR Department
Expected Query
SELECT *
FROM Employees
WHERE Department = 'HR';Exercise 14
Find Employees In HR Or IT
Expected Query
SELECT *
FROM Employees
WHERE Department IN
(
'HR',
'IT'
);Exercise 15
Find Employees Not In Finance
Expected Query
SELECT *
FROM Employees
WHERE Department <> 'Finance';Exercise 16
Display Unique Departments
Expected Query
SELECT DISTINCT Department
FROM Employees;Exercise 17
Find Employees With Salary Between 60000 And 80000
Expected Query
SELECT *
FROM Employees
WHERE Salary
BETWEEN 60000
AND 80000;Exercise 18
Find Employees Whose Name Starts With R
Expected Query
SELECT *
FROM Employees
WHERE EmployeeName LIKE 'R%';Exercise 19
Find Employees Whose Name Ends With A
Expected Query
SELECT *
FROM Employees
WHERE EmployeeName LIKE '%a';Exercise 20
Find Employees Whose Name Contains H
Expected Query
SELECT *
FROM Employees
WHERE EmployeeName LIKE '%h%';Exercise 21
Count Employees Per Department
Expected Query
SELECT
Department,
COUNT(*) AS TotalEmployees
FROM Employees
GROUP BY Department;Exercise 22
Find Average Salary Per Department
Expected Query
SELECT
Department,
AVG(Salary) AS AvgSalary
FROM Employees
GROUP BY Department;Exercise 23
Find Maximum Salary Per Department
Expected Query
SELECT
Department,
MAX(Salary)
FROM Employees
GROUP BY Department;Exercise 24
Find Departments Having More Than One Employee
Expected Query
SELECT
Department,
COUNT(*)
FROM Employees
GROUP BY Department
HAVING COUNT(*) > 1;Exercise 25
Display Top 3 Highest Paid Employees
MySQL/PostgreSQL
SELECT *
FROM Employees
ORDER BY Salary DESC
LIMIT 3;SQL Server
SELECT TOP 3 *
FROM Employees
ORDER BY Salary DESC;Exercise 26
Create Employees Table
Expected Query
CREATE TABLE Employees
(
EmployeeID INT,
EmployeeName VARCHAR(100),
Department VARCHAR(50),
Salary DECIMAL(10,2)
);Exercise 27
Insert New Employee
Expected Query
INSERT INTO Employees
VALUES
(
6,
'Karan',
'IT',
75000
);Exercise 28
Update Employee Salary
Expected Query
UPDATE Employees
SET Salary = 80000
WHERE EmployeeID = 1;Exercise 29
Delete Employee
Expected Query
DELETE
FROM Employees
WHERE EmployeeID = 6;Exercise 30
Create Department Table
Expected Query
CREATE TABLE Departments
(
DepartmentID INT,
DepartmentName VARCHAR(100)
);Exercise 31
Perform INNER JOIN
Expected Query
SELECT *
FROM Employees E
INNER JOIN Departments D
ON E.DepartmentID =
D.DepartmentID;Exercise 32
Perform LEFT JOIN
Expected Query
SELECT *
FROM Employees E
LEFT JOIN Departments D
ON E.DepartmentID =
D.DepartmentID;Exercise 33
Find Employees With NULL Manager
Expected Query
SELECT *
FROM Employees
WHERE ManagerID IS NULL;Exercise 34
Use CASE Expression
Expected Query
Exercise 35
Create a View
Expected Query
CREATE VIEW HighSalaryEmployees AS
SELECT *
FROM Employees
WHERE Salary > 70000;Exercise 36
Find Second Highest Salary
Expected Query
SELECT MAX(Salary)
FROM Employees
WHERE Salary <
(
SELECT MAX(Salary)
FROM Employees
);Exercise 37
Find Duplicate Department Values
Expected Query
SELECT
Department,
COUNT(*)
FROM Employees
GROUP BY Department
HAVING COUNT(*) > 1;Exercise 38
Count Employees With Salary Greater Than 60000
Expected Query
SELECT COUNT(*)
FROM Employees
WHERE Salary > 60000;Exercise 39
Find Employee With Highest Salary
Expected Query
SELECT *
FROM Employees
ORDER BY Salary DESC
LIMIT 1;Exercise 40
Find Employee With Lowest Salary
Expected Query
SELECT *
FROM Employees
ORDER BY Salary ASC
LIMIT 1;Beginner Practice Checklist
Complete these topics before moving ahead:
✓ SELECT
✓ WHERE
✓ ORDER BY
✓ GROUP BY
✓ HAVING
✓ Aggregate Functions
✓ LIKE
✓ BETWEEN
✓ CRUD Operations
✓ Basic JOINs
✓ CASE
✓ ViewsChallenge Section
Try solving without looking at answers:
Challenge 1
Find employees earning more than average salary.
Challenge 2
Find department with highest average salary.
Challenge 3
Find employees whose names contain exactly 5 characters.
Challenge 4
Find employees whose salary is not between 50000 and 70000.
Challenge 5
Display employees sorted by department then salary.
Summary
These beginner exercises help build a strong foundation in SQL by covering querying, filtering, sorting, grouping, aggregation, CRUD operations, joins, and basic database concepts.
After completing these exercises, you should be comfortable writing and understanding everyday SQL queries.
Next Step
Continue to:
SQL Exercises (Intermediate) →
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for SQL Exercises Beginner.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this SQL topic.
Search Terms
sql, sql complete guide, sql tutorial, sql notes, complete, guide, practice, exercises
Related SQL Topics