Practise 15 commonly asked SQL interview questions for BTech freshers. Learn SELECT, JOIN, GROUP BY, subqueries, window functions and database concepts with examples.
SQL Questions Commonly Asked in Placements: 15 Queries Every Fresher Must Practise
Preparing for technical interviews at companies like TCS, Infosys, Wipro, Cognizant, Accenture, or Capgemini? There is one subject you simply cannot afford to ignore: SQL.
Whether you are applying for a software developer, analyst, or entry-level IT role, interviewers often test your understanding of databases and your ability to write SQL queries.
The good news is that most fresher-level SQL questions revolve around a few important concepts. Master these, and you will be better prepared for both technical assessments and interviews.
Here are 15 SQL questions every BTech fresher should practise.
1. Understand the SQL Fundamentals First
Before attempting complex queries, understand these basic concepts:
- SELECT and WHERE
- ORDER BY and GROUP BY
- DISTINCT
- INSERT, UPDATE and DELETE
- Primary and foreign keys
- Aggregate functions
- Joins
- Subqueries
- Constraints
You should also understand the difference between DELETE, TRUNCATE, and DROP.
2. Practise These 15 Common SQL Interview Questions
For the following examples, assume you have two tables:
Employees
| emp_id | name | salary | dept_id |
|---|---|---|---|
| 1 | Rahul | 50000 | 10 |
| 2 | Priya | 65000 | 20 |
| 3 | Amit | 45000 | 10 |
| 4 | Neha | 80000 | 30 |
| 5 | Karan | 65000 | 20 |
Departments
| dept_id | dept_name |
|---|---|
| 10 | Engineering |
| 20 | Analytics |
| 30 | HR |
Question 1: Display all employees earning more than ₹50,000.
SELECT *
FROM Employees
WHERE salary > 50000;Concept: SELECT and WHERE.
Question 2: Find the highest salary.
SELECT MAX(salary)
FROM Employees;Concept: Aggregate functions.
Question 3: Find the second-highest distinct salary.
SELECT MAX(salary)
FROM Employees
WHERE salary < (
SELECT MAX(salary)
FROM Employees
);Concept: Subqueries and aggregate functions.
Question 4: Count the number of employees in each department.
SELECT dept_id, COUNT(*) AS total
FROM Employees
GROUP BY dept_id;Concept: GROUP BY and COUNT.
Question 5: Find departments having more than one employee.
SELECT dept_id, COUNT(*) AS total
FROM Employees
GROUP BY dept_id
HAVING COUNT(*) > 1;Concept: HAVING versus WHERE.
Question 6: Display employee names along with department names.
SELECT e.name, d.dept_name
FROM Employees e
INNER JOIN Departments d
ON e.dept_id = d.dept_id;Concept: INNER JOIN.
Question 7: Find employees earning more than the average salary.
SELECT *
FROM Employees
WHERE salary > (
SELECT AVG(salary)
FROM Employees
);Concept: Subqueries and AVG.
Question 8: Find duplicate salary values.
SELECT salary, COUNT(*)
FROM Employees
GROUP BY salary
HAVING COUNT(*) > 1;Concept: GROUP BY and HAVING.
Question 9: Display employees in descending order of salary.
SELECT *
FROM Employees
ORDER BY salary DESC;Concept: ORDER BY.
Question 10: Find the top three highest-paid employees.
SELECT *
FROM Employees
ORDER BY salary DESC
LIMIT 3;Concept: Sorting and limiting results. Note that SQL Server uses TOP instead of LIMIT.
Question 11: Find employees whose names start with 'A'.
SELECT *
FROM Employees
WHERE name LIKE 'A%';Concept: Pattern matching.
Question 12: Find employees who do not belong to any department.
SELECT e.*
FROM Employees e
LEFT JOIN Departments d
ON e.dept_id = d.dept_id
WHERE d.dept_id IS NULL;Concept: LEFT JOIN and NULL values.
Question 13: Find the third-highest distinct salary using DENSE_RANK.
SELECT salary
FROM (
SELECT salary,
DENSE_RANK() OVER (
ORDER BY salary DESC
) AS rnk
FROM Employees
) ranked
WHERE rnk = 3;Concept: Window functions.
Question 14: Find employees earning the same salary.
SELECT e1.name, e2.name, e1.salary
FROM Employees e1
JOIN Employees e2
ON e1.salary = e2.salary
AND e1.emp_id < e2.emp_id;Concept: Self JOIN.
Question 15: Find the highest-paid employee in each department.
SELECT name, dept_id, salary
FROM (
SELECT name, dept_id, salary,
RANK() OVER (
PARTITION BY dept_id
ORDER BY salary DESC
) AS rnk
FROM Employees
) ranked
WHERE rnk = 1;Concept: PARTITION BY and RANK.
3. Understand These Five Important SQL Concepts
Apart from query writing, interviewers frequently test your conceptual understanding.
| Concept | What you should know |
|---|---|
| Primary Key | Uniquely identifies each record |
| Foreign Key | Establishes a relationship between tables |
| INNER JOIN | Returns matching records from both tables |
| LEFT JOIN | Returns all left-table records and matching right-table records |
| GROUP BY vs HAVING | GROUP BY creates groups; HAVING filters groups |
Also understand the difference between WHERE and HAVING, UNION and UNION ALL, and RANK and DENSE_RANK.
4. How to Prepare for SQL Interviews in 7 Days
| Day | Preparation focus |
|---|---|
| Day 1 | SELECT, WHERE, DISTINCT, ORDER BY |
| Day 2 | Aggregate functions and GROUP BY |
| Day 3 | INNER JOIN, LEFT JOIN, RIGHT JOIN |
| Day 4 | Subqueries and nested queries |
| Day 5 | Constraints, keys and database fundamentals |
| Day 6 | Window functions and advanced queries |
| Day 7 | Timed SQL mock test and revision |
Don't just read the queries. Write them yourself, execute them, and experiment with different inputs.
5. Combine SQL Preparation with Complete Placement Preparation
SQL is only one part of a technical interview. You should also strengthen your programming fundamentals and problem-solving skills.
Practise DSA coding practice questions, revise OOPs concepts, and prepare common technical interview questions for freshers.
Use an online mock test for placement to evaluate your preparation. An adaptive placement practice test can help you identify weaker topics.
For company-specific recruitment, practise relevant DBMS and SQL technical MCQ practice and company-specific placement papers.
Students preparing for TCS can also explore TCS NQT preparation 2026.
An AI mock interview online can help you practise explaining SQL queries and technical concepts confidently.
Start Your SQL Preparation with Prephasz
The key to cracking SQL interview questions is consistent hands-on practice. Understanding the logic behind a query is far more valuable than memorising its syntax.
Prephasz helps BTech students prepare for service-based IT company placements through company-specific learning materials, technical MCQs, coding practice, aptitude tests, mock interviews, and an ATS-friendly resume builder.
Don't just learn SQL. Practise writing queries, understand database concepts, and build the confidence to explain your solutions in an interview. Start preparing with Prephasz today!
Put this into practice
Drill these exact patterns with adaptive practice, timed mocks and company-wise assessments on prephasz.
Start practising free

