5 SQL interview questions every fresher should practise
Second highest salary, duplicates, LEFT JOIN, daily practice and matching real job requirements: the SQL basics fresher interviews keep asking.
Published by Hirastra
Second highest salary
The most repeated SQL question. Use a subquery with MAX. For the Nth highest, use DENSE_RANK() OVER (ORDER BY salary DESC) and filter rank = N.
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);Find duplicate rows
Group by the column and filter groups with HAVING. WHERE filters rows before grouping, HAVING filters groups after.
SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1;JOINs with no match
To find customers who never ordered, use LEFT JOIN and keep rows where the right side is NULL. Use IS NULL, never = NULL.
SELECT c.name FROM customers c LEFT JOIN orders o ON c.id = o.customer_id WHERE o.id IS NULL;Practise on real data
Solve Easy problems first and aim for 2 a day. Cover JOINs, GROUP BY, subqueries and window functions.
leetcode.com/problemset/database hackerrank.com/domains/sqlCheck openings that ask SQL
See today's verified openings, read the skills listed, and match the SQL level to what you are practising. Apply early with official links.
hirastra.com/today
Skip the searching: today's verified openings are posted three times a day with official apply links, and you can check your resume against any of them with the free ATS checker.