If you’re preparing for a technical job or placement round, mastering the basic SQL queries for interview is the first step. Whether you’re a fresher or switching careers into tech, SQL remains a core skill for data handling and database interaction.
In this guide, you’ll learn the top 20 most asked basic SQL queries, along with examples and explanations. Let’s dive in!
🚀 Why Learn Basic SQL Queries for Interview?
Companies from startups to MNCs like TCS, Wipro, Infosys, and Capgemini often test your grasp of fundamental SQL queries. These help assess how comfortable you are working with data tables, filters, conditions, and aggregations.
✅ 20 Basic SQL Queries for Interview (With Examples)
1. Select all data from a table
SELECT * FROM Employees;
This is the simplest SQL query used to fetch all rows and columns from the table.
2. Select specific columns
SELECT Name, Age FROM Employees;
3. Use WHERE clause to filter data
sql EditSELECT * FROM Employees WHERE Department = 'HR';
4. Filter with multiple conditions
SELECT * FROM Employees WHERE Department = 'IT' AND Age > 25;
5. Sort results using ORDER BY
SELECT * FROM Employees ORDER BY Salary DESC;
6. Get unique/distinct values
SELECT DISTINCT Department FROM Employees;
7. Count number of records
SELECT COUNT(*) FROM Employees;
8. Find average salary
SELECT AVG(Salary) FROM Employees;
9. Find minimum and maximum salary
SELECT MIN(Salary), MAX(Salary) FROM Employees;
10. Group data by a column
SELECT Department, COUNT(*) FROM Employees GROUP BY Department;
11. Using HAVING with GROUP BY
SELECT Department, COUNT(*)
FROM Employees
GROUP BY Department
HAVING COUNT(*) > 2;
12. Insert data into table
INSERT INTO Employees (Name, Age, Department)
VALUES ('Ankit', 28, 'Marketing');
13. Update existing records
UPDATE Employees
SET Salary = 50000
WHERE Name = 'Ankit';
14. Delete a record
DELETE FROM Employees WHERE Name = 'Ankit';
15. Rename a column (alias)
SELECT Name AS EmployeeName FROM Employees;
16. Use BETWEEN for range filter
SELECT * FROM Employees WHERE Salary BETWEEN 30000 AND 60000;
17. Use IN to match multiple values
SELECT * FROM Employees WHERE Department IN ('IT', 'HR');
18. NULL check in SQL
sql EditSELECT * FROM Employees WHERE Manager IS NULL;
19. LIMIT clause to restrict rows
SELECT * FROM Employees LIMIT 5;
20. Using LIKE for pattern match
SELECT * FROM Employees WHERE Name LIKE 'A%';
🎯 Pro Interview Tips
- Understand what each SQL query does, not just how it looks.
- Be prepared to modify queries based on interviewer inputs.
- Know how to join tables, even at a basic level.
- Practice writing these without copy-pasting to gain speed.
❓ FAQs – Basic SQL Queries for Interview
Q1: Are these basic SQL queries enough for interviews?
Yes, for entry-level roles and freshers, these cover 80% of what is asked. Mastering these gives you an edge.
Q2: Where can I practice these SQL queries?
You can use:
Q3: Should I memorize the queries?
No, focus on understanding them. You should be able to modify the queries in real-time during an interview.
🧠 Final Thoughts
Learning these basic SQL queries for interview sets the foundation for more advanced concepts. Practice each one multiple times, and try to tweak it to understand the underlying logic.