50 SQL QUERY-BASED INTERVIEW QUESTIONS-2026
Beginner
49 Questions
Fresher Friendly
Updated Oct 2026
Search by question or keyword.
Follow Quizer
Interview Questions and Answers
Expand a question to view the answer and interview tip.
SELECT * FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT DISTINCT department FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT COUNT(*) FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT MAX(salary) FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT name, salary FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees WHERE salary > 50000;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees WHERE joining_date > '2023-01-01';
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees WHERE name LIKE 'A%';
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees ORDER BY salary DESC;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees LIMIT 5;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees WHERE salary BETWEEN 30000 AND 60000;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees WHERE department IN ('IT','HR');
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees WHERE manager_id IS NULL;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT department, COUNT(*) FROM employees GROUP BY department;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT department, SUM(salary) FROM employees GROUP BY department;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 3;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees e LEFT JOIN departments d ON e.dept_id = d.id WHERE d.id IS NULL;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT e.name, d.dept_name FROM employees e INNER JOIN departments d ON e.dept_id = d.id;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT e.name, d.dept_name FROM employees e LEFT JOIN departments d ON e.dept_id = d.id;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT e.name, d.dept_name FROM employees e RIGHT JOIN departments d ON e.dept_id = d.id;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees WHERE joining_date >= CURDATE() - INTERVAL 30 DAY;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
DELETE t1 FROM users t1 JOIN users t2 ON t1.email = t2.email AND t1.id > t2.id;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
UPDATE employees SET salary = salary * 1.10;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
INSERT INTO employees (name, salary, dept_id) VALUES ('Rahul',55000,3);
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT emp_id, COUNT(*) FROM tasks GROUP BY emp_id HAVING COUNT(*) > 2;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT department, MAX(salary) FROM employees GROUP BY department;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT department, COUNT(*) AS num FROM employees GROUP BY department ORDER BY num DESC LIMIT 1;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET N-1;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT REPLACE(name,'Mr.','') FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT CONCAT(name,' - ',email) AS info FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT name, CASE WHEN salary > 70000 THEN 'High' WHEN salary > 40000 THEN '2' ELSE 'Low' END AS salary_level FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT e1.name, e2.name, e1.salary FROM employees e1 JOIN employees e2 ON e1.salary = e2.salary AND e1.id < e2.id;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees ORDER BY id LIMIT 5 OFFSET 5;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT name, salary, RANK() OVER (ORDER BY salary DESC) AS rank_no FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT name, salary, SUM(salary) OVER (ORDER BY id) AS running_total FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT name, salary, DENSE_RANK() OVER (ORDER BY salary DESC) FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT id + 1 AS missing_id FROM employees e WHERE NOT EXISTS (SELECT 1 FROM employees x WHERE x.id = e.id + 1);
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT department, SUM(CASE WHEN gender='M' THEN 1 ELSE 0 END) AS male, SUM(CASE WHEN gender='F' THEN 1 ELSE 0 END) AS female FROM employees GROUP BY department;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
DELETE FROM employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
TRUNCATE TABLE employees;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT emp_id, COUNT(DISTINCT dept_id) FROM emp_dept GROUP BY emp_id HAVING COUNT(DISTINCT dept_id) > 1;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT a.name AS employee, b.name AS manager FROM employees a JOIN employees b ON a.manager_id = b.id;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT name FROM employees WHERE manager_id IS NULL;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT * FROM employees ORDER BY joining_date DESC LIMIT 3;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT department, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM employees) AS percentage FROM employees GROUP BY department;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.
SELECT salary, COUNT(*) FROM employees GROUP BY salary HAVING COUNT(*) > 1;
Interview Tip:
Keep your answer structured and support it
with practical examples wherever possible.