Practice Day (SELECT, WHERE, ORDER BY, LIMIT)
1. Sample Table for Practice
employees
| emp_id | emp_name | department | salary | city |
|---|---|---|---|---|
| 1 | Ravi | IT | 45000 | Chennai |
| 2 | Priya | HR | 38000 | Coimbatore |
| 3 | Arjun | IT | 52000 | Bangalore |
| 4 | Meena | Finance | 41000 | Chennai |
| 5 | Karthik | IT | 30000 | Madurai |
| 6 | Anu | HR | 36000 | Chennai |
2. Practice Queries with Solutions
Q1: Display all employee details
SELECT * FROM employees;
Q2: Display employee name and salary
SELECT emp_name, salary FROM employees;
Q3: Display employees with salary greater than 40000
SELECT * FROM employees
WHERE salary > 40000;
Q4: Display IT department employees
SELECT * FROM employees
WHERE department = 'IT';
Q5: Display employees from Chennai city
SELECT * FROM employees
WHERE city = 'Chennai';
Q6: Display employees whose name starts with 'A'
SELECT * FROM employees
WHERE emp_name LIKE 'A%';
Q7: Display employees with salary between 35000 and 45000
SELECT * FROM employees
WHERE salary BETWEEN 35000 AND 45000;
Q8: Display employees in IT or HR department
SELECT * FROM employees
WHERE department IN ('IT', 'HR');
Q9: Display top 3 highest paid employees
SELECT * FROM employees
ORDER BY salary DESC
LIMIT 3;
Q10: Display employees sorted by name
SELECT * FROM employees
ORDER BY emp_name ASC;
Revision, Quiz & Interview Preparation
1. Revision Summary (Day 1–5)
✔ SQL basics & databases
✔ CREATE, INSERT, SELECT
✔ WHERE clause
✔ Operators
✔ ORDER BY & LIMIT
2. SQL Quiz (Test Yourself)
Q1: Which keyword removes duplicate values?
A) UNIQUE
B) DISTINCT ✅
C) DIFFERENT
Q2: Which clause filters rows?
A) SELECT
B) WHERE ✅
C) ORDER BY
Q3: Default order in ORDER BY?
A) DESC
B) ASC ✅
Q4: Which operator checks a range?
A) IN
B) BETWEEN ✅
Q5: Which clause limits rows?
A) LIMIT ✅
B) WHERE
3. Common Interview Questions (Beginner)
Q: Difference between WHERE and HAVING?
WHERE filters rows
HAVING filters groups (after GROUP BY)
Q: What is DISTINCT?
Removes duplicate value
Q: Can ORDER BY be used without SELECT?
No
4. Real-Time Scenario Questions
*Find top 5 salary employees
*Find employees from specific city
*Filter records using multiple conditions
*Sort employee data for reports
5.Self-Assessment Task
Create a table students with:
- student_id
- student_name
- marks
- city
✔ Insert 5 records
✔ Write queries:
- Top 2 highest marks
- Students from Chennai
- Marks between 60 and 90
Top comments (1)
Great day 6 content for SQL beginners. Building fundamentals through these daily lessons is the right approach. For those starting their SQL journey, consistent daily practice is key. Complementing tutorials with hands-on problem sets accelerates learning. sql-practice.online is a great resource for beginners to apply concepts learned from tutorials like these through real-world scenarios. #database #beginners #learning