Skip to content

Image, PDF and QR tools that run in your browser. Your files never leave your phone. Explore tools →

SQL Interview Questions for Freshers

Resume & career100% freePrivate

The short answer

SQL rounds usually ask about queries and keys. The bank has 10 questions, including WHERE versus HAVING, inner versus left join, primary, unique and foreign keys, normalisation, DELETE versus TRUNCATE versus DROP, and indexes. Each has notes on what to say.

How do you want to use it?

10 questions. Open one to see what a good answer covers.

What is the difference between WHERE and HAVING?
SQL and databases

WHERE filters rows before grouping and cannot use aggregate functions. HAVING filters groups after GROUP BY and can use aggregates such as COUNT or SUM.

What is the difference between INNER JOIN and LEFT JOIN?
SQL and databases

INNER JOIN returns only rows that match in both tables. LEFT JOIN returns every row of the left table and fills the right table's columns with NULL where there is no match.

What are a primary key, a unique key and a foreign key?
SQL and databases

A primary key identifies each row uniquely and cannot be NULL. A unique key also stops duplicates but allows a NULL. A foreign key points to a primary key in another table to link them.

What is normalisation?
SQL and databases

Organising tables to reduce repeated data and mistakes. First normal form has single values in each cell, second removes partial dependencies and third removes dependencies between non-key columns.

What is the difference between DELETE, TRUNCATE and DROP?
SQL and databases

DELETE removes chosen rows and can be rolled back. TRUNCATE removes all rows quickly and keeps the table. DROP removes the whole table and its structure.

What is an index, and when can it hurt?
SQL and databases

An index is a structure that makes searches on a column faster. It speeds up reads but slows inserts and updates and uses space, so index the columns you filter and join on, not everything.

What are the ACID properties?
SQL and databases

Atomicity (all or nothing), Consistency (rules always hold), Isolation (transactions do not disturb each other) and Durability (committed data survives a crash). They keep transactions reliable.

How would you find the second highest salary?
SQL and databases

One way is to select the maximum salary below the overall maximum, using a subquery. Another is to use DENSE_RANK or LIMIT with OFFSET. Mention duplicates and what you want when two people share a salary.

What is the difference between a subquery and a join?
SQL and databases

A subquery is a query inside another, a join combines tables side by side. Joins are often faster and clearer, while subqueries can be easier to read for simple filters.

What is a view?
SQL and databases

A saved query that behaves like a virtual table. It hides complexity, can restrict what users see and does not store data itself, unless it is a materialised view.

Everything runs in your browser. What you type is not sent anywhere.

How to: SQL Interview Questions for Freshers

  1. 1Read the question and write a sample query on paper.
  2. 2Open the tip and check the points you missed.
  3. 3Say the difference aloud as if to a colleague.
  4. 4Practise again with the timer.

At a glance

Questions
10 SQL and database questions
Includes
Joins, keys, normalisation, indexes
Time to aim for
About 60 seconds each

Frequently asked questions

What is the easiest way to explain a join?

Say that a join combines rows from two tables on a matching column. An inner join keeps only matches, and a left join also keeps unmatched rows from the left table.

Will I be asked to write queries?

Very often. Practise on a small sample table with a few students and marks, and be ready to explain your result row by row.

More quick answers