50 SQL QUERY-BASED INTERVIEW QUESTIONS-2026
📘 Beginner
49 Questions
🎯 Fresher Friendly
🕒 Updated Mar 2026
SELECT * FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT DISTINCT department FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT COUNT(*) FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT MAX(salary) FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT name, salary FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees WHERE salary > 50000;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees WHERE joining_date > '2023-01-01';
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees WHERE name LIKE 'A%';
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees ORDER BY salary DESC;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees LIMIT 5;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees WHERE salary BETWEEN 30000 AND 60000;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees WHERE department IN ('IT','HR');
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees WHERE manager_id IS NULL;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT department, COUNT(*) FROM employees GROUP BY department;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT department, SUM(salary) FROM employees GROUP BY department;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 3;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees e LEFT JOIN departments d ON e.dept_id = d.id WHERE d.id IS NULL;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT e.name, d.dept_name FROM employees e INNER JOIN departments d ON e.dept_id = d.id;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT e.name, d.dept_name FROM employees e LEFT JOIN departments d ON e.dept_id = d.id;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT e.name, d.dept_name FROM employees e RIGHT JOIN departments d ON e.dept_id = d.id;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees WHERE joining_date >= CURDATE() - INTERVAL 30 DAY;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1;
💡 Interview Tip:
Keep answers structured and give real examples.
DELETE t1 FROM users t1 JOIN users t2 ON t1.email = t2.email AND t1.id > t2.id;
💡 Interview Tip:
Keep answers structured and give real examples.
UPDATE employees SET salary = salary * 1.10;
💡 Interview Tip:
Keep answers structured and give real examples.
INSERT INTO employees (name, salary, dept_id) VALUES ('Rahul',55000,3);
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT emp_id, COUNT(*) FROM tasks GROUP BY emp_id HAVING COUNT(*) > 2;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT department, MAX(salary) FROM employees GROUP BY department;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT department, COUNT(*) AS num FROM employees GROUP BY department ORDER BY num DESC LIMIT 1;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET N-1;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT REPLACE(name,'Mr.','') FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT CONCAT(name,' - ',email) AS info FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT name, CASE WHEN salary > 70000 THEN 'High' WHEN salary > 40000 THEN '2' ELSE 'Low' END AS salary_level FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
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 answers structured and give real examples.
SELECT * FROM employees ORDER BY id LIMIT 5 OFFSET 5;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT name, salary, RANK() OVER (ORDER BY salary DESC) AS rank_no FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT name, salary, SUM(salary) OVER (ORDER BY id) AS running_total FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT name, salary, DENSE_RANK() OVER (ORDER BY salary DESC) FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
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 answers structured and give real examples.
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 answers structured and give real examples.
DELETE FROM employees;
💡 Interview Tip:
Keep answers structured and give real examples.
TRUNCATE TABLE employees;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT emp_id, COUNT(DISTINCT dept_id) FROM emp_dept GROUP BY emp_id HAVING COUNT(DISTINCT dept_id) > 1;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT a.name AS employee, b.name AS manager FROM employees a JOIN employees b ON a.manager_id = b.id;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT name FROM employees WHERE manager_id IS NULL;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT * FROM employees ORDER BY joining_date DESC LIMIT 3;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT department, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM employees) AS percentage FROM employees GROUP BY department;
💡 Interview Tip:
Keep answers structured and give real examples.
SELECT salary, COUNT(*) FROM employees GROUP BY salary HAVING COUNT(*) > 1;
💡 Interview Tip:
Keep answers structured and give real examples.
Share this Post
Monthly Challenge
Compete with top learners & win exciting prizes
LIVE NOW
🎁 Rewards + Certificate
Participate →