SQL Interview Questions for Freshers
Preparing for a data role? Explore the most common SQL interview questions for freshers, with clear examples, practical tips, and a free interview guide.
Table of Contents
- Why SQL Interview Questions Matter So Much for Freshers
- How to Approach SQL Fresher Interview Preparation
- Basic SQL Interview Questions for Freshers
- What is SQL, and what is it used for?
- What is the difference between DDL, DML, and DQL?
- What is a Primary Key?
- What is a Foreign Key?
- What is the difference between WHERE and HAVING?
- What are the different types of JOINs in SQL?
- What is Normalisation?
- Intermediate SQL Interview Questions for Freshers
- What is the difference between DELETE, TRUNCATE, and DROP?
- What is a Subquery?
- What are Aggregate Functions?
- What is the difference between UNION and UNION ALL?
- Write a query to find the second-highest salary from an Employees table.
- What is an Index, and why is it used?
- Common Mistakes and Practical Tips for SQL Interviews
- Final Thoughts
If you're a fresher preparing for your first data role, chances are you've already Googled "SQL interview questions" at least once this week. It's one of the most common — and most nerve-wracking — parts of any interview for a data analyst, business analyst, or entry-level developer position. The good news is that SQL interviews for freshers tend to follow a fairly predictable pattern, and once you understand what recruiters are actually testing for, the preparation becomes a lot less overwhelming.
This guide walks you through the most frequently asked SQL interview questions, explains the logic behind each answer, and gives you a realistic sense of what to expect in an entry-level interview. Whether you're a student, a professional switching careers, or applying for roles in Delhi NCR's growing analytics job market, this is meant to be a practical reference you can actually use. These SQL Interview Questions will help you focus on the concepts and query patterns that commonly appear in fresher interviews.
Why SQL Interview Questions Matter So Much for Freshers
Almost every data-related role — analyst, developer, tester, even some marketing and operations positions — expects at least working knowledge of SQL. For freshers, interviewers usually aren't expecting production database experience; they're checking whether you understand how relational data works and can think logically about queries. That's why SQL interview questions asked to freshers are rarely about memorised trivia. They're about problem-solving: Can you write a query that pulls the right data? Can you explain what a JOIN actually does? Recruiters use these questions as a filter — not to trip you up, but to see how you approach a data problem.
How to Approach SQL Fresher Interview Preparation
Before jumping into the question list, it helps to have a study plan rather than randomly memorising answers. A structured approach to SQL fresher interview preparation usually looks like this: Before practising SQL Interview Questions, make sure your SQL fundamentals are clear. 
- Understand the "why," not just the "how." Knowing that GROUP BY groups rows is not enough — know when and why you'd use it.
- Practice writing queries by hand. Many interviews ask you to write SQL on a whiteboard or shared doc, without autocomplete.
- Work with a real dataset. Set up a small database (even a sample e-commerce or student database works) and run your own queries against it.
- Revisit basic concepts daily in the week before your interview — JOINs, keys, normalisation, and aggregate functions tend to come up repeatedly. If you're building your broader analytics skills alongside SQL, our Data Analytics Learning Guide can help you follow a structured learning path.
If you're just starting, it's worth going through a SQL Basics Tutorial for Students before attempting the interview-style questions below — having the fundamentals solid makes everything else click faster. You can also browse more tutorials on the SPARC blog if you want to revise other data analytics topics alongside SQL.
Basic SQL Interview Questions for Freshers
These are the questions you should be able to answer without hesitation. They test foundational understanding. These SQL Interview Questions for freshers cover the core concepts you should be comfortable explaining in an interview.

What is SQL, and what is it used for?
SQL (Structured Query Language) is used to communicate with relational databases — to create, read, update, and delete data (often shortened to CRUD operations). It's the standard language for managing structured data stored in tables. For additional fundamentals, you can also refer to the official PostgreSQL SQL tutorial.
What is the difference between DDL, DML, and DQL?
| Category |
Full Form |
Purpose |
Common Commands |
| DDL |
Data Definition Language |
Defines database structure |
CREATE, ALTER, DROP, TRUNCATE |
| DML |
Data Manipulation Language |
Manipulates data within tables |
INSERT, UPDATE, DELETE |
| DQL |
Data Query Language |
Retrieves data |
SELECT |
A quick way to remember this: DDL changes the structure, DML changes the data, and DQL just reads the data.
What is a Primary Key?
A Primary Key is a column (or combination of columns) that uniquely identifies each row in a table. It cannot contain NULL values, and a table can have only one primary key.
Example: In a Students table, student_id would typically be the primary key, since no two students share the same ID.
What is a Foreign Key?
A Foreign Key is a column that creates a link between two tables by referencing the Primary Key of another table. It's how relational databases maintain relationships between related data.
Example: A course_id column in a Students table might reference the course_id in a Courses table, connecting each student to the course they're enrolled in. These foundational SQL Interview Questions help interviewers check whether you understand how tables and relationships work.
What is the difference between WHERE and HAVING?
This is one of the most commonly asked SQL interview questions, and it trips up a lot of freshers.
- WHERE filters rows before any grouping happens, and it cannot be used with aggregate functions.
- HAVING filters groups after the GROUP BY operation, and it's specifically designed to work with aggregate functions like SUM(), COUNT(), or AVG().
Example:
SELECT department, COUNT(*) AS total_employees
FROM Employees
WHERE status = 'Active'
GROUP BY department
HAVING COUNT(*) > 10;
Here, WHERE filters active employees first, and HAVING filters departments that end up with more than 10 people after grouping. You can also review the MySQL SELECT documentation for the official syntax and usage of WHERE, GROUP BY, and HAVING.
What are the different types of JOINs in SQL?
JOINs combine rows from two or more tables based on a related column. This is arguably the most important concept for SQL fresher interview preparation, since almost every real-world query involves joining tables.
| JOIN Type |
What It Returns |
| INNER JOIN |
Only matching rows from both tables |
| LEFT JOIN |
All rows from the left table, matched rows from the right |
| RIGHT JOIN |
All rows from the right table, matched rows from the left |
| FULL OUTER JOIN |
All rows from both tables, matched where possible |
| SELF JOIN |
A table joined with itself |
Interviewers often follow up by asking you to write a query using a JOIN — so don't just. For additional examples and syntax, see the official MySQL JOIN documentation. Memorise the definitions; practice writing them out.SQL is one of several tools used in analytics. Explore these Data Analytics Tools You Must Know to understand how SQL fits into a broader analytics toolkit. JOIN-based SQL Interview Questions are especially useful for testing practical query-writing skills.

What is Normalisation?
Normalisation organises data in a database to reduce redundancy and improve data integrity by breaking large tables into smaller, related tables and defining relationships between them using keys.
The most commonly discussed normal forms in interviews:
- 1NF: Each column holds atomic (indivisible) values.
- 2NF: Removes partial dependency on a composite key.
- 3NF: Removes transitive dependency — non-key columns shouldn't depend on other non-key columns.
You don't need textbook definitions word-for-word, but you should be able to explain, in plain language, why normalisation matters — mainly, it avoids storing the same data in multiple places, which reduces errors during updates.
Intermediate SQL Interview Questions for Freshers
Once the basics are covered, interviewers often move into slightly more applied territory. The following SQL Interview Questions focus more on practical problems and applied SQL concepts.
What is the difference between DELETE, TRUNCATE, and DROP?
| Command |
Removes |
Can Rollback? |
Resets Auto-Increment? |
| DELETE |
Specific rows (with WHERE) |
Yes |
No |
| TRUNCATE |
All rows in a table |
Database-dependent* |
Yes |
| DROP |
The entire table structure |
No |
N/A |
*In some databases (like PostgreSQL), TRUNCATE can be rolled back if it's run inside a transaction. In others (like MySQL with certain storage engines), it typically cannot. It's worth mentioning this nuance if an interviewer pushes on the topic.
A good way to explain this in an interview: DELETE is selective and reversible, TRUNCATE clears everything quickly but keeps the table structure, and DROP removes the table entirely.
What is a Subquery?
A subquery is a query nested inside another query, often used to filter results based on the output of the inner query.
Example:
SELECT name
FROM Employees
WHERE department_id IN (
SELECT department_id FROM Departments WHERE location = 'Delhi'
);
Here, the inner query fetches department IDs located in Delhi, and the outer query uses that result to filter employees. For more examples of nested queries and subqueries, see the MySQL subqueries documentation.
What are Aggregate Functions?
Aggregate functions perform a calculation on a set of values and return a single value. The common ones are:
- COUNT() — counts rows
- SUM() — adds up numeric values
- AVG() — calculates the average
- MIN() / MAX() — finds the smallest or largest value
These are usually paired with GROUP BY when you want the aggregation broken down by category (like sales per region, or average marks per subject).
What is the difference between UNION and UNION ALL?
Both combine the results of two SELECT statements, but:
- UNION removes duplicate rows from the combined result.
- UNION ALL keeps all rows, including duplicates, and is faster since it skips the deduplication step.
Write a query to find the second-highest salary from an Employees table.
This is a classic, almost guaranteed question in fresher interviews:
SELECT MAX(salary) AS second_highest_salary
FROM Employees
WHERE salary < (SELECT MAX(salary) FROM Employees);
There's also a LIMIT/OFFSET approach that many interviewers accept, and it's worth knowing as a second option:
SELECT DISTINCT salary
FROM Employees
ORDER BY salary DESC
LIMIT 1 OFFSET 1;
The DISTINCT keeps duplicate salary values from throwing off the result. Mentioning both approaches — and explaining that DENSE_RANK() is another option for more complex ranking scenarios — shows the interviewer you understand the problem rather than having memorised one fixed answer. This is one of the SQL Interview Questions worth practising repeatedly because it tests your ability to apply SQL logic to a real problem.
What is an Index, and why is it used?
An index is a database object that improves the speed of data retrieval operations on a table. Think of it like the index at the back of a textbook — instead of scanning every page, the database can jump directly to the relevant data.
The trade-off: indexes speed up reads but can slow down writes (INSERT/UPDATE/DELETE), since the index also needs to be updated. This is a good point to bring up if the interviewer asks about pros and cons. You can learn more about how indexes are used to improve query performance in the MySQL index documentation.

Common Mistakes and Practical Tips for SQL Interviews
Knowing the concepts isn't always enough — how you present your answer matters too. A few mistakes freshers commonly make: While answering SQL Interview Questions, avoid focusing only on the final query; explain your reasoning as well.
- Jumping straight to syntax without explaining logic. Interviewers want to see your thought process, not just the final query.
- Confusing WHERE and HAVING, or using them interchangeably in explanations.
- Not asking clarifying questions. If a question is ambiguous (e.g., "find duplicate records"), it's fine to ask what counts as a duplicate before writing the query.
- Going silent when stuck, instead of talking through your reasoning — partial credit is real in most interviews.
A few things that genuinely help on the day:
- Revise JOINs and subqueries the night before — they show up in almost every interview.
- Practice writing queries on paper or a whiteboard, not just in an IDE with autocomplete.
- Keep a small personal "cheat sheet" of query patterns you review before any interview, not just your first one.
- If you want structured, hands-on practice instead of just reading, working through some SQL Queries Explained Easily can help bridge the gap between theory and application.
For those exploring where this preparation eventually leads, it's worth understanding the SQL Developer Career Opportunities once you're past the interview stage — SQL skills stay relevant across analyst, developer, and even product roles.
Final Thoughts
Preparing for SQL interview questions doesn't have to mean memorising an endless list of definitions. Practising SQL Interview Questions regularly can also make it easier to explain your SQL logic clearly during an interview. Focus on understanding the logic behind JOINs, keys, and aggregate functions, practice writing queries without autocomplete, and get comfortable explaining your reasoning out loud. That combination — conceptual clarity plus hands-on practice — is what actually gets freshers through SQL interview rounds.
If you're planning to build SQL and other analytics skills systematically, explore our Data Analytics Course: Eligibility & Career Opportunities to understand the skills and career paths involved.
If you'd like a more structured version of this preparation, along with practice questions and answer explanations, you can download our interview guide and work through it at your own pace before your next interview.
[Download Interview Guide]
FAQs
Be comfortable with SELECT statements, JOINs, GROUP BY/HAVING, subqueries, and basic concepts like keys and normalization. Window functions and query optimization are a bonus, not a requirement, at this stage.
Yes — practicing on any SQL sandbox with a sample database is a good way to build syntax comfort and confidence before your interview.