Almost every campus placement for IT services, analytics and product companies includes SQL, in the online test, the technical interview or both. The good news: the same twenty or so patterns come up again and again, and you can master them in a few focused weeks.
This path is built for students and freshers with no work experience. It goes from your first SELECT to the questions placement panels actually ask: second highest salary, duplicates, employees earning more than their manager, department-wise top earners, plus the DBMS theory (keys, normalization, ACID) that fills the viva. Every module links to a live lesson you can run in your browser, so you practise instead of just reading.
Every SQL answer starts here: choose columns with SELECT, rows with WHERE, and combine conditions with AND, OR, IN, BETWEEN and LIKE. Panels often test NULL handling here: = NULL never matches anything, so you need IS NULL.
SELECT name, department_id, salary
FROM employees
WHERE salary BETWEEN 50000 AND 90000
AND name LIKE 'A%'
AND manager_id IS NOT NULL;
ORDER BY sorts (ascending by default), DISTINCT removes duplicate rows from the result, and LIMIT / TOP / FETCH FIRST return only the first N rows. Knowing the syntax differences between MySQL, SQL Server and Oracle is a common viva question.
SELECT DISTINCT department_id
FROM employees
ORDER BY department_id;
SELECT name, salary
FROM employees
ORDER BY salary DESC
LIMIT 3; -- SQL Server: SELECT TOP 3 ... Oracle: FETCH FIRST 3 ROWS ONLY
ORDER BY. Without it the database may return rows in any order, even if it looks sorted today.Aggregate functions (COUNT, SUM, AVG, MIN, MAX) summarize groups created by GROUP BY. WHERE filters rows before grouping; HAVING filters groups after. "WHERE vs HAVING" is one of the most asked fresher questions.
SELECT department_id, COUNT(*) AS employees, AVG(salary) AS avg_salary
FROM employees
WHERE hire_date >= '2021-01-01'
GROUP BY department_id
HAVING COUNT(*) >= 2;
SELECT must appear in GROUP BY. Forgetting this is the most common error in online tests.JOINs combine tables on a related column. INNER JOIN keeps only matches; LEFT JOIN keeps every row from the left table, with NULLs where there's no match. A self join joins a table to itself, which is the classic way to compare an employee with their manager.
-- Classic: employees who earn more than their manager
SELECT e.name AS employee, e.salary, m.name AS manager, m.salary AS manager_salary
FROM employees e
JOIN employees m ON m.id = e.manager_id
WHERE e.salary > m.salary;
A subquery is a query inside another query. It's the traditional answer to placement favourites like "find the second highest salary" and "employees earning above the average". Know at least two ways to solve each; panels often ask "can you do it another way?".
-- Second highest salary (handles duplicates of the top salary)
SELECT MAX(salary) AS second_highest
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
-- Employees earning more than the company average
SELECT name, salary
FROM employees
WHERE salary > (SELECT AVG(salary) FROM employees);
Window functions calculate across related rows without collapsing them. They're now standard in placement interviews for product and analytics companies. The top question: "highest paid employee in each department", solved with DENSE_RANK() partitioned by department.
SELECT department_id, name, salary
FROM (
SELECT department_id, name, salary,
DENSE_RANK() OVER (PARTITION BY department_id ORDER BY salary DESC) AS rnk
FROM employees
) t
WHERE rnk = 1;
ROW_NUMBER 1,2,3, RANK 1,1,3 and DENSE_RANK 1,1,2.A small set of problems appears in placement tests year after year: find duplicate rows, delete duplicates keeping one, count employees per department including empty departments, find departments with no employees, and display the Nth highest salary. Practise until you can write each in under three minutes.
-- Find duplicate emails
SELECT email, COUNT(*) AS copies
FROM customers
GROUP BY email
HAVING COUNT(*) > 1;
-- Departments with no employees
SELECT d.name
FROM departments d
LEFT JOIN employees e ON e.department_id = d.id
WHERE e.id IS NULL;
The technical viva goes beyond queries. Expect: primary vs foreign vs unique key; DDL vs DML vs DCL vs TCL; DELETE vs TRUNCATE vs DROP; 1NF, 2NF and 3NF with an example; ACID properties of transactions; and what an index is and when not to use one.
Turn practice into confidence before placement season.
Placement rounds usually include an online test (MCQs and query writing) and a technical interview. These resources cover both, and the 2-week plan below keeps you on track.
The most asked basic SQL interview questions.
Join questions, from basic to self joins.
MCQ practice similar to online placement tests.
25 questions covering everything above. Score 80% or higher to earn your Campus Placement Ready badge on your dashboard.
25 questions · pass at 80%+ to earn your Campus Placement Ready badge on your dashboard. One-time payment, lifetime access.