Training Trains logo

SQL Interview Questions for Freshers

By K. Boopathikumar, CEO & Founder · 1 November 2026 · Updated 22 November 2026 · 5 min read

SQL appears in interviews for many roles, not only database jobs. The good news is that the same few ideas come up again and again.

Be clear on the basics: SELECT, WHERE, ORDER BY, GROUP BY and HAVING. Know the difference between WHERE and HAVING: WHERE filters rows, and HAVING filters groups.

Joins are asked often. Be able to explain inner and left joins, and draw a small example on paper with two tables.

Expect common problems such as the second highest salary, finding duplicates and counting orders per customer. Practise writing these without looking them up.

Understand keys and normalisation well enough to explain them simply. Say your thinking aloud as you answer, because interviewers want to see how you reason as well.

Eight questions with short answers

  • What is the difference between DELETE, TRUNCATE and DROP? DELETE removes chosen rows, TRUNCATE empties the table, and DROP removes the table itself.
  • What is a primary key? A column, or set of columns, that identifies each row and cannot be empty or repeated.
  • What is a foreign key? A column that refers to a key in another table, so that an order cannot belong to a customer who does not exist.
  • INNER JOIN or LEFT JOIN? INNER keeps only matching rows. LEFT keeps every row of the first table and shows NULL where there is no match.
  • UNION or UNION ALL? UNION removes duplicate rows, and UNION ALL keeps them and is usually faster.
  • What is NULL? A missing value. It is not zero or an empty string, and you test it with IS NULL.
  • What is an index? A structure that helps the database find rows quickly. It takes space and makes inserts a little slower.
  • What is normalisation? Arranging tables so that each fact is stored once, which avoids contradictions.

Three queries to practise until they are easy

  • Second highest salary: SELECT MAX(salary) FROM employee WHERE salary < (SELECT MAX(salary) FROM employee);
  • Duplicate emails: SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1;
  • Customers with no orders: SELECT c.name FROM customer c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL;

How to answer when you are stuck

Write the tables and two or three sample rows on paper. Say what the result should look like, and then build the query one clause at a time, starting with FROM. Interviewers usually give credit for a clear method even when the syntax is not perfect. Also mention ties: if two people share the top salary, does your answer still hold?

Keep practising with our SQL learning path and the PostgreSQL DBA interview questions.

Looking for an internship near Erode?

10 days to 6 months, online or at our Erode and Perundurai branches, with real tasks reviewed by our team.

More guides