Skip to content
Live on Product Hunt

We just launched BrainUp on Product Hunt. Thanks for coming over!

BrainUp
  • Templates
  • Resume Guides
  • Blog
  • Pricing
  • Contact
Log inBuild Resume
  • Templates
  • Resume Guides
  • Blog
  • Pricing
  • Contact
  • Log in
Build My Resume — Free
BrainUp

Build your resume. Then build your advantage. The career productivity toolkit for your whole job search.

Products

  • Free Resume Builder
  • Cover Letter Builder
  • LinkedIn Optimizer (Premium)
  • AI Interview Prep (Premium)
  • Job Tracker (Premium)

Resources

  • Resume Templates
  • Resume Guides
  • Career Blog

Company

  • Pricing
  • Contact us

Legal

  • Terms
  • Privacy
  • Cookies

© 2026 BrainUp. All rights reserved. ·

BrainUp is a career productivity tool, not a recruitment agency. We help you prepare — we don't guarantee interviews, job offers or ATS outcomes.

BrainUp

  1. Home
  2. SQL Interview Questions for Freshers

SQL interview prep

SQL Interview Questions for Freshers: Answer With Confidence

Fresher SQL interviews mostly test joins, GROUP BY with HAVING, keys and constraints, subqueries and one or two window functions, followed by a short query you write live. Practise those five areas and you cover most rounds.

Practise with AI Interview PrepSee SQL developer resume
  • 20 questions answered
  • Query examples
  • Fresher level
  • Data and developer roles

Sample answers

How a strong fresher answers out loud.

Short, correct and with an example. Interviewers prefer a crisp answer plus a small query over a long definition.

Model answers for 4 frequently asked questions

Use the structure: definition, example, when you would use it

Q: What is the difference between WHERE and HAVING? A: WHERE filters rows before grouping, HAVING filters groups after GROUP BY. For example, SELECT dept, COUNT(*) FROM employees GROUP BY dept HAVING COUNT(*) > 5 returns only departments with more than five employees.

Q: Explain INNER JOIN vs LEFT JOIN. A: INNER JOIN returns only rows that match in both tables. LEFT JOIN returns every row from the left table and fills NULLs where the right table has no match, which is useful for finding customers with no orders.

Q: How do you find the second highest salary? A: SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees). With window functions, use DENSE_RANK() OVER (ORDER BY salary DESC) and pick rank 2, which also handles ties.

Q: What is a primary key vs a unique key? A: Both prevent duplicates. A table has one primary key and it cannot be NULL; it can have several unique keys, and in most databases a unique column can hold NULL.

Q: What does normalization mean? A: Organising tables to remove duplicate data and update anomalies. In practice, first normal form means atomic values, second removes partial dependency on a composite key, and third removes columns that depend on other non-key columns.

What interviewers check

Built for scanners, humans and hiring intent.

  • Join logic

    Can you choose the right join and explain why rows appear or disappear? Expect at least one join question.

  • Grouping and filtering

    GROUP BY, HAVING and aggregate functions show whether you can turn raw rows into answers.

  • Writing a query live

    Most rounds include a short query on a whiteboard or shared editor. Clear aliases and formatting help.

  • Database basics

    Keys, constraints, normalization and indexes tell the interviewer you understand how data is stored.

Examples

Copy the structure, not the wording.

These examples show shape and specificity. Add your own facts, metrics, tools and outcomes.

Basic questions

  • What is SQL and how is it different from MySQL?
  • What are DDL, DML, DCL and TCL commands?
  • What is the difference between DELETE, TRUNCATE and DROP?
  • What is a foreign key?
  • What is an index and why does it speed up reads?

Query questions

  • Find duplicate emails in a users table.
  • Show the top 3 earners in each department.
  • Count orders per customer, including customers with zero orders.
  • Get employees who joined in the last 30 days.
  • Find departments whose average salary is above the company average.

Scenario questions

  • A report query is slow on a large table. What would you check first?
  • Two tables have mismatched customer IDs. How would you find the gaps?
  • How would you remove duplicate rows but keep one copy?
  • Sales data has NULL regions. How do you report them as 'Unknown'?
  • When would you use a view instead of a table?

Actionable tips

Small edits that lift response rates.

Run through these before every application.

  1. 1Say the query out loudExplain each clause as you write it: tables, joins, filters, grouping, ordering. It shows structured thinking even if you make a typo.
  2. 2Know execution orderFROM, WHERE, GROUP BY, HAVING, SELECT, ORDER BY. This one fact answers many 'why does this fail' questions.
  3. 3Practise five patternsSecond highest value, duplicates, top N per group, running totals and anti-joins cover most fresher query tasks.
  4. 4Mention NULL handlingCOALESCE, IS NULL and how NULLs behave in joins and counts are common follow-ups.
  5. 5Rehearse with feedbackPractise answering aloud with BrainUp AI Interview Prep, then put your SQL projects on your resume so the interviewer asks about them.

FAQ

Common questions, direct answers.

What is SQL?

SQL (Structured Query Language) is the standard language for creating, reading, updating and deleting data in relational databases such as MySQL, PostgreSQL, SQL Server and Oracle.

What is the difference between WHERE and HAVING?

WHERE filters individual rows before grouping. HAVING filters groups after GROUP BY, so it can use aggregates like COUNT or SUM in its condition.

What are the types of joins in SQL?

INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, CROSS JOIN and SELF JOIN. Inner returns matches only; outer joins keep unmatched rows from one or both sides with NULLs.

What is the difference between DELETE, TRUNCATE and DROP?

DELETE removes selected rows and can use WHERE. TRUNCATE removes all rows quickly but keeps the table structure. DROP removes the table itself, including its structure.

What is a primary key?

A primary key uniquely identifies each row in a table. It cannot contain NULL values, and a table can have only one primary key, which may span multiple columns.

What is a foreign key?

A foreign key is a column that references the primary key of another table. It enforces referential integrity, so you cannot insert an order for a customer that does not exist.

What is normalization?

Normalization organises data into related tables to reduce duplication and update anomalies. Freshers should explain 1NF, 2NF and 3NF with a simple example.

What is an index in SQL?

An index is a data structure, usually a B-tree, that lets the database find rows without scanning the whole table. It speeds up reads but adds cost to inserts and updates.

How do you find the second highest salary in SQL?

Use SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees), or DENSE_RANK() over salary in descending order and filter for rank 2.

How do you find duplicate records in a table?

Group by the columns that should be unique and keep groups with more than one row: SELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1.

What is a subquery?

A subquery is a query nested inside another query. It can return a single value, a list for IN, or a table used in FROM. A correlated subquery runs once per outer row.

What is the difference between UNION and UNION ALL?

UNION combines results and removes duplicate rows. UNION ALL keeps every row, including duplicates, and is faster because it skips the duplicate check.

What are aggregate functions?

Aggregate functions calculate one value from many rows: COUNT, SUM, AVG, MIN and MAX. They are usually combined with GROUP BY to summarise data per group.

What are window functions?

Window functions such as ROW_NUMBER, RANK, DENSE_RANK and SUM() OVER calculate values across related rows without collapsing them, useful for rankings and running totals.

What is the difference between RANK and DENSE_RANK?

Both give tied rows the same rank. RANK leaves gaps after ties (1, 1, 3), while DENSE_RANK does not (1, 1, 2).

What is a view?

A view is a saved SELECT query that behaves like a virtual table. It simplifies complex queries and can restrict which columns users see, but it usually stores no data itself.

What is the order of execution of a SQL query?

Logically: FROM and JOIN, WHERE, GROUP BY, HAVING, SELECT, DISTINCT, ORDER BY, then LIMIT or TOP. That is why column aliases from SELECT cannot be used in WHERE.

What is a NULL value and how do you check for it?

NULL means a missing or unknown value, not zero or an empty string. Check it with IS NULL or IS NOT NULL, because comparisons like = NULL never return true.

What is a stored procedure?

A stored procedure is a named set of SQL statements saved in the database and run with one call. It can take parameters and is used for repeatable business logic.

How should a fresher prepare for an SQL interview?

Revise joins, grouping, keys and window functions, solve 30-50 practice queries on a sample schema, and be ready to explain one project where you used SQL.

Related guides

Keep improving your application.

  • SQL Developer ResumeTurn your query skills into a resume that gets the interview.View SQL resume →
  • Data Analyst ResumeSQL is the core skill for analyst roles. See how to present it.View analyst resume →
  • Resume for FreshersThe first-job resume format to pair with your interview prep.Read fresher guide →

Practise SQL interview answers before the real round

BrainUp AI Interview Prep asks role-specific questions and gives feedback on your answers.

Start interview practiceBrowse templates

The resume builder and PDF downloads are free. AI tools are part of BrainUp Premium.