Data & BINovember 4, 202623 min read

Top SQL Interview Questions & Answers (2026)

17 questions SQL Developer interviewers actually ask, with the strong answer, the weak one, and the follow-up that comes next.

  • SQL DeveloperRole
  • $75K-$120KTypical US pay
  • 3-4 roundsInterview loop
  • Nice to haveCert in hiring
  • UsuallyHands-on test
SQL interview questions and answers - interviewer and candidate speech bubbles

SQL and database developers are hired by banks, insurers, healthcare systems, retailers, software vendors and consultancies, anywhere data sits in Oracle, SQL Server, PostgreSQL or a cloud warehouse. In 2026 nearly every interview for these roles includes a live SQL test, often in a shared editor or online coding platform, plus questions on joins, NULLs, window functions, indexing and how transactions behave under concurrent load.

The Oracle Database SQL Certified Associate proves you know the language precisely, including the tricky edges like NULL logic, set operators and Oracle-specific functions that trip people up. Interviewers then test what the exam can't: whether you can turn a messy business question into correct, efficient SQL, read an execution plan, explain where Oracle behaves differently from other databases, and avoid damaging production data.

What the SQL Developer interview loop looks like

Most SQL Developer / Database Developer hiring runs 4 rounds. Each one is testing something different, so prepare for each separately.

1
Recruiter screenRecruiter or HR · 20-30 minDatabases you've used, years of SQL, reporting versus application work, salary rangeTip: Name the platforms and versions you've worked with and the size of the data. 'Strong SQL' without specifics sounds like everyone else.
2
Online SQL assessmentAutomated platform or take-home · 45-90 minJoins, aggregation, window functions and subqueries on a small schema, scored for correctnessTip: Read the schema first, check for NULLs and duplicate keys, and test edge cases. Correct beats clever.
3
Technical interviewSenior developer, DBA or data lead · 60 minLive query writing, explaining NULL behaviour, indexing, execution plans, transactions and lockingTip: Talk through your query before running it and state assumptions about the data. Mention how you'd verify the result.
4
Hiring manager and teamEngineering or BI manager · 45 minWorking with analysts and app developers, production safety, how you handle data quality problemsTip: Bring one story where your SQL fixed a business problem, and one where you prevented or recovered from a data mistake.

The 17 questions, with answers

Each card shows the question as it is usually asked, what the interviewer is really checking, a strong answer, the weak answer they hear most often, and the follow-up that comes next. Say the strong answers in your own words — a memorised script sounds memorised.

  • Basic · 4
  • Core · 5
  • Advanced · 3
  • Scenario · 3
  • Behavioural · 2
Basic · 4Warm-up questions. Fluff these and the rest of the interview is uphill.
Q01BasicDisplaying Data from Multiple Tables
Interviewer

Explain inner, left outer and full outer joins. What's a common mistake people make with left joins?

What they are testing: Join semantics and the WHERE-clause trap that silently turns outer joins into inner ones

Strong answer

An inner join returns only rows that match in both tables. A left outer join returns every row from the left table, with NULLs for the right table's columns where there's no match. A full outer join returns all rows from both sides, matched where possible. The classic mistake is filtering on the right table's columns in the WHERE clause, like WHERE o.status = 'OPEN', after a left join. Rows with no match have NULL there, the condition is unknown, so they're removed and you've effectively written an inner join. The filter belongs in the ON clause. Oracle also has the old (+) outer join syntax, but I write ANSI joins.

Weak answerA left join is just a join that includes more rows. Too vague, and misses where to put conditions.
Next they will askHow would you find customers who have never placed an order, in two different ways?
Q02BasicConversion Functions and Conditional Expressions
Interviewer

How does NULL behave in comparisons, aggregate functions and NOT IN?

What they are testing: Three-valued logic, the source of many wrong results in production

Strong answer

NULL means unknown, so any comparison with it, even NULL = NULL, is unknown rather than true, and WHERE only keeps true rows. You test with IS NULL or IS NOT NULL. Aggregates ignore NULLs: COUNT(*) counts rows, COUNT(column) counts non-null values, and AVG divides only by non-null values. The nasty one is NOT IN: if the subquery returns even one NULL, NOT IN returns no rows, so I prefer NOT EXISTS. One Oracle-specific point: Oracle treats an empty string as NULL, so '' IS NULL is true there but not in PostgreSQL or SQL Server. For replacements I use COALESCE, which is ANSI, or Oracle's NVL.

Weak answerNULL is the same as zero or an empty string. Wrong in every database, and produces wrong totals and filters.
Next they will askWhat does AVG(bonus) return compared to SUM(bonus)/COUNT(*) when some bonuses are NULL?
Q03BasicReporting Aggregated Data Using Group Functions
Interviewer

What's the difference between WHERE and HAVING? Why can't I put an aggregate in the WHERE clause?

What they are testing: Logical query processing order

Strong answer

WHERE filters individual rows before grouping, and HAVING filters groups after the aggregates are calculated. Logically, a query is processed as FROM and joins, then WHERE, then GROUP BY, then HAVING, then SELECT, then ORDER BY. Aggregates like SUM or COUNT don't exist yet when WHERE runs, so they go in HAVING. That order also explains why you can use a column alias in ORDER BY but not in WHERE. And in Oracle, every non-aggregated column in the SELECT list has to appear in GROUP BY, otherwise you get an error. Some MySQL configurations are looser about that, which can hide bugs.

Weak answerHAVING is just another WHERE you use with GROUP BY. Doesn't explain the order or why it matters.
Next they will askWrite a query for departments with more than five employees earning over 50,000. Where does each filter go?
Q04BasicUse DDL to manage tables and their relationships
Interviewer

What's the difference between a primary key, a unique constraint and a foreign key?

What they are testing: Data integrity basics and one practical Oracle performance detail

Strong answer

A primary key uniquely identifies each row and can't be NULL, and a table has at most one. A unique constraint also prevents duplicates, but its columns can be NULL. In Oracle multiple rows can have NULL in a single-column unique constraint, while SQL Server's unique constraint allows only one NULL. A foreign key makes sure a value exists in the parent table, and in Oracle you can add ON DELETE CASCADE or ON DELETE SET NULL. Oracle creates an index automatically for primary and unique constraints, but not for foreign keys. I usually index foreign key columns, because unindexed ones can cause locking problems and slow joins and deletes on the parent.

Weak answerThey're all ways of saying a column is important. Shows no grasp of integrity rules.
Next they will askWhy might deleting one parent row lock a whole child table in Oracle?
Core · 5The day-to-day knowledge the job runs on. Most of the score comes from here.
Q05CoreBeyond the exam: analytic (window) functions
Interviewer

Write a query that returns the second-highest salary in each department. How do ties change your answer?

What they are testing: Window functions and choosing between ROW_NUMBER, RANK and DENSE_RANK

Strong answer

I'd use a window function in a subquery: SELECT department_id, employee_id, salary, DENSE_RANK() OVER (PARTITION BY department_id ORDER BY salary DESC) AS rnk FROM employees, then wrap it and filter WHERE rnk = 2. You can't filter on a window function in the same query's WHERE because it's calculated after WHERE. The ties question decides the function. DENSE_RANK gives the second distinct salary, so two people tied at the top don't push the next salary to third. RANK would leave a gap, so there might be no rank two at all. ROW_NUMBER picks exactly one row per position, arbitrarily among ties unless I add a tiebreaker.

Weak answerUse MAX(salary) where salary is less than MAX(salary). Works for one department, gets messy per department and hides tie handling.
Next they will askNow return the top three earners per department, including everyone tied for third.
Q06CoreBeyond the exam: analytic (window) functions
Interviewer

How would you calculate a running total of daily sales, and what's the gotcha with ties?

What they are testing: Window frames, the default RANGE behaviour that surprises people

Strong answer

SUM(amount) OVER (ORDER BY sale_date) gives a running total, and adding PARTITION BY store_id restarts it per store. The gotcha: when you specify ORDER BY without a frame, the default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. RANGE treats rows with the same ORDER BY value as peers, so if there are several rows for one date, they all get the same total, including all of that day's sales. If I want it to grow row by row I write ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW and add a unique tiebreaker to the ORDER BY. Often the cleaner answer is to aggregate to one row per day first.

Weak answerUse a self-join summing all earlier rows. Works but is slow, and misses the window function entirely.
Next they will askHow would you compute a seven-day moving average instead?
Q07CoreUsing Subqueries to Solve Queries
Interviewer

When would you use a subquery instead of a join? What's a correlated subquery?

What they are testing: Choosing constructs by meaning, not habit, and avoiding duplicate rows

Strong answer

I choose by what the question means. If I need columns from both tables, it's a join. If I just need to check whether related rows exist, EXISTS or IN is clearer and avoids a common bug: joining customers to orders to find customers with orders duplicates customers who ordered several times, while EXISTS returns each customer once. A correlated subquery references the outer query, like WHERE EXISTS (SELECT 1 FROM orders o WHERE o.customer_id = c.customer_id), so logically it's evaluated per outer row. Modern optimizers, Oracle's included, often rewrite these into joins anyway, so I focus on correctness first, then check the plan. For not-exists checks I use NOT EXISTS because of NOT IN's NULL problem.

Weak answerSubqueries are always slower, so I always use joins. Outdated rule and can produce duplicate rows.
Next they will askWrite an UPDATE that sets each employee's salary to their department's average, using a correlated subquery.
Q08CoreUsing SET Operators
Interviewer

What's the difference between UNION and UNION ALL? When does it matter?

What they are testing: Set operator semantics and their performance cost

Strong answer

UNION combines results and removes duplicate rows, which means the database has to sort or hash the combined set. UNION ALL keeps every row and skips that work. If the two queries can't overlap, say this year's and last year's partitions, UNION ALL is faster and I'd use it. If duplicates are possible and must be removed, UNION is correct. Both need the same number of columns with compatible types, and column names come from the first query. ORDER BY goes once at the end. Oracle also has INTERSECT and MINUS; other databases call MINUS EXCEPT, and recent Oracle releases accept EXCEPT too, but MINUS is what you'll see in most Oracle code.

Weak answerThey're the same, UNION ALL is just longer to type. Misses duplicate removal and its cost.
Next they will askHow would you find rows in a staging table that aren't in the target table yet?
Q09CoreManaging Indexes Synonyms and Sequences
Interviewer

How does an index speed up a query, and when won't the optimizer use one?

What they are testing: Practical indexing knowledge and common reasons indexes are ignored

Strong answer

A B-tree index stores the key values in sorted order with pointers to the rows, so the database can find a few matching rows without scanning the whole table. It helps most for selective filters and join columns. It often won't be used when the column is wrapped in a function, like UPPER(last_name), unless there's a function-based index; when there's an implicit type conversion, like comparing a VARCHAR2 column to a number; with a leading wildcard like '%son'; or when the filter matches so many rows a full scan is cheaper. In Oracle, a regular B-tree index doesn't store entries where all key columns are NULL, so IS NULL searches can't use a single-column index.

Weak answerAdd an index on every column and queries will be fast. Ignores write cost, storage and why indexes get skipped.
Next they will askHow would you confirm whether a query used the index you expected?
Advanced · 3Depth checks. They separate the cert holder from the practitioner.
Q10AdvancedManaging Tables using DML statements
Interviewer

Explain transaction isolation levels. What does Oracle do differently from other databases?

What they are testing: Concurrency anomalies and vendor-specific behaviour

Strong answer

The ANSI standard defines read uncommitted, read committed, repeatable read and serializable, which progressively prevent dirty reads, non-repeatable reads and phantom reads. Oracle supports read committed, its default, and serializable, plus a read-only mode. It never allows dirty reads. Oracle uses multiversion read consistency: a query sees data as of the moment it started, built from undo, so readers don't block writers and writers don't block readers, except with SELECT FOR UPDATE. SQL Server by default implements read committed with shared locks unless snapshot options are enabled, so readers can be blocked there. Also, in Oracle any DDL statement commits the current transaction implicitly, so mixing DDL into a transaction is risky.

Weak answerIsolation levels are about security and who can see tables. Confuses isolation with access control.
Next they will askTwo sessions update the same row at the same time in Oracle. What exactly happens?
Q11AdvancedRelational Database concepts
Interviewer

Walk me through normalisation up to third normal form. When would you deliberately denormalise?

What they are testing: Data modelling fundamentals and pragmatic trade-offs

Strong answer

First normal form means each column holds a single value and there are no repeating groups, so no comma-separated lists of phone numbers. Second normal form means every non-key column depends on the whole primary key, which matters with composite keys. Third normal form means non-key columns don't depend on other non-key columns, so I don't store customer city on every order when it belongs to the customer. Normalised designs reduce duplication and update anomalies, which suits transactional systems. I'd denormalise for reporting, like a star schema in a warehouse, or a carefully maintained summary column when a read is very hot, and only with a clear process that keeps the copies consistent.

Weak answerNormalisation means making tables smaller. Can't explain dependencies or when to break the rules.
Next they will askAn orders table stores the product price. Is that a normalisation mistake?
Q12AdvancedManaging Tables using DML statements
Interviewer

How do you write an upsert in Oracle, and what are the common MERGE pitfalls?

What they are testing: Practical DML and vendor differences

Strong answer

In Oracle I use MERGE INTO target USING source ON the join condition, WHEN MATCHED THEN UPDATE, WHEN NOT MATCHED THEN INSERT. Two pitfalls come up a lot. First, if the source has more than one row matching the same target row, Oracle raises an unable to get a stable set of rows error, so I deduplicate the source first. Second, Oracle won't let you update columns referenced in the ON clause. I also check what triggers and constraints will fire. Syntax differs elsewhere: SQL Server also has MERGE, PostgreSQL commonly uses INSERT ON CONFLICT, and MySQL uses INSERT ON DUPLICATE KEY UPDATE. So I name the database before writing one.

Weak answerDelete the row if it exists, then insert it again. Breaks foreign keys, fires extra triggers and loses history.
Next they will askHow would you also delete target rows that no longer exist in the source?
Scenario · 3Something is broken or ambiguous. They want your reasoning out loud, in order.
Q13ScenarioManaging Indexes Synonyms and Sequences
Interviewer

A report query that ran in two seconds last month now takes two minutes. How do you investigate?

What they are testing: Methodical performance troubleshooting rather than guessing

Strong answer

I'd ask what changed: data volume, the query, the parameters, or the database. Then I'd get the actual execution plan, in Oracle with DBMS_XPLAN, and compare it with the old plan if it's in history. Common culprits are a plan change after statistics were updated or went stale, a full scan where an index was used before, an implicit conversion after a column type or parameter type changed, or a join that now multiplies rows because of new duplicate data. I'd also check whether it's waiting on locks rather than working. Once I find the cause, I fix the root issue, like statistics, an index or a rewritten predicate, and verify with realistic data.

Weak answerAdd more indexes until it's fast. Guessing without reading the plan can make things worse.
Next they will askThe plan shows estimated rows of 10 but actual rows of 2 million. What does that tell you?
Q14ScenarioManaging Tables using DML statements
Interviewer

You run an UPDATE in production and realise it had no WHERE clause. What do you do?

What they are testing: Honesty, transaction awareness and recovery options

Strong answer

If I haven't committed, I roll back straight away. That's why I run changes inside an explicit transaction and check the affected row count before committing. If it's already committed, I tell my lead and the DBA immediately rather than trying to hide it. In Oracle, a flashback query, SELECT AS OF TIMESTAMP, can often show the old values if the undo data is still available, and the DBA may have other flashback or backup options. Applications should be paused if they rely on that table. Afterwards, I'd suggest guardrails: peer review for production changes, running the matching SELECT first, and not having write access by default.

Weak answerQuietly write another UPDATE to fix it and hope nobody notices. Hiding incidents is a firing offence.
Next they will askWhy wouldn't a DDL statement you ran afterwards help, and how could it make things worse?
Q15ScenarioReporting Aggregated Data Using Group Functions
Interviewer

Finance says your dashboard's monthly revenue doesn't match their number. How do you track down the difference?

What they are testing: Reconciliation skills and knowledge of where SQL silently goes wrong

Strong answer

I'd get finance's exact definition and their number for one specific month, then reconcile step by step. First, totals before any joins, to see if joins are multiplying rows, which happens when joining to a table with several rows per order. Then filters: which statuses count, are refunds and cancellations excluded, how are NULL amounts treated. Then date boundaries: in Oracle a DATE includes a time, so BETWEEN two dates can miss the last day's sales after midnight, and time zones can shift orders across months. I'd find the rows that differ, agree the definition with finance, fix the query, and document the definition next to the dashboard.

Weak answerOur number comes from the database, so finance must be wrong. Defensive and skips reconciliation.
Next they will askYou find one order counted three times. What exactly in the query would you look at?
Behavioural · 2How you work with people. Templates below - fill them with your own story.
Q16BehaviouralSoft skills
Interviewer

Tell me about a time you had to explain a technical data problem to someone non-technical.

What they are testing: Communication with analysts, managers and business users

Strong answer (template)

Template to fill with your own story. Situation: a sales manager believed a report was broken because numbers changed after a refresh. Task: I needed to explain that late-arriving orders were being backdated. Action: I showed one example order, when it was placed versus when it reached the database, used a simple before-and-after table instead of SQL, and proposed adding a 'data as of' timestamp to the report. Result: the manager understood, trust in the report improved, and the timestamp became standard on our dashboards. Focus on one concrete example and a practical fix, not on how clever the query was.

Weak answerI just tell them it's a database thing and they wouldn't understand. Shows poor collaboration.
Next they will askHow do you handle it when a stakeholder insists on a number you know is wrong?
Q17BehaviouralSoft skills
Interviewer

Describe a time you improved a slow or fragile piece of SQL someone else wrote.

What they are testing: Initiative, respect for existing code and measurable impact

Strong answer (template)

Template to fill with your own story. Situation: a nightly job took hours because of row-by-row processing in a loop. Task: I was asked to make it finish before business hours. Action: I read the existing logic carefully, wrote set-based SQL that produced the same results, compared outputs on a copy of production data, and walked the original author through the change before deploying it. Result: runtime dropped from hours to minutes and the job stopped failing on busy nights. Mention how you proved the results matched, and that you worked with the original author rather than around them.

Weak answerThe old code was terrible, so I rewrote everything my way. Sounds risky and disrespectful of teammates.
Next they will askHow did you make sure your rewrite returned exactly the same results as the original?

Get the theory airtight before the interview

Interviewers build follow-ups on the fundamentals. ExamCert AI has exam-style Oracle 1Z0-071 questions with an explanation for every option, so the basics stay automatic when the questions get harder.

Practise on ExamCert AIFree Oracle 1Z0-071 practice test

The practical task

Expect some version of this. Companies vary the details, not the shape.

PRACTICAL TASKWrite reporting queries against a small sales schemaLive coding, 45-60 min, shared SQL editor

You get four tables: customers, orders, order_items and products. Write queries for: monthly revenue for the last 12 months; the top three products by revenue in each category; customers who ordered last year but not this year; and each customer's running total spend. Some orders have NULL discounts and some customers have no orders. Explain your choices as you write.

  1. Inspect the tables first: keys, row counts, NULL columns and whether order_items can have several rows per product.
  2. Aggregate revenue from order_items with COALESCE for NULL discounts, grouping by a truncated month with clear date bounds.
  3. Use DENSE_RANK or ROW_NUMBER partitioned by category for top three, and state how ties are handled.
  4. Find lapsed customers with NOT EXISTS or MINUS, explaining why NOT IN is risky if any value can be NULL.
  5. Write the running total with SUM OVER and an explicit ROWS frame, then sanity-check one customer by hand.

Hire vs no-hire:Hires check the data before writing, handle NULLs and ties explicitly, avoid join fan-out and verify a sample result. No-hires write long queries straight away and never check whether the totals are right.

Questions to ask them

"Do you have any questions for us?" is still being scored. Four that land well for a SQL Developer role:

Which databases and versions do you run, and is there a migration planned?Shows you know SQL dialects differ, and tells you whether you'll need PostgreSQL, SQL Server or cloud warehouse skills too.
How do database changes reach production, and who reviews them?Signals you care about production safety and tells you whether migrations are scripted, version-controlled and reviewed.
What's the split between application SQL, reporting and performance work in this role?Clarifies the real job and shows you're thinking about where you can add value from day one.
What's the biggest data quality problem the team is dealing with right now?Gets them talking about real pain points and gives you a chance to show how you'd approach it.

Mistakes that sink candidates

MistakeWriting a query before looking at keys, NULLs and duplicatesInsteadSay what you'd check first: grain of each table, nullable columns and join cardinality. It prevents most wrong answers.
MistakeUsing NOT IN with a subquery without mentioning NULLsInsteadUse NOT EXISTS, or explain that a single NULL in the subquery makes NOT IN return nothing.
MistakeClaiming one syntax works everywhereInsteadName the database. Point out where Oracle differs, like empty strings as NULL, MINUS, NVL and implicit commit on DDL.
MistakeFixing slow queries by adding indexes blindlyInsteadRead the execution plan first, find the real cause, and mention the write and storage cost of every index.
MistakeNever mentioning how you'd verify a resultInsteadReconcile totals, check row counts before and after joins, and test edge cases like ties, NULLs and empty groups.

What the Oracle Database SQL Certified Associate does and does not prove

What the Oracle Database SQL Certified Associate gets you

The Oracle Database SQL Certified Associate is respected in organisations that run Oracle, such as banks, insurers, government and large enterprises, and it helps career changers and graduates show SQL competence on paper. It's rarely a hard requirement, since most SQL roles test you directly, but it can get a resume noticed where Oracle experience is listed as preferred.

What it does not prove

The exam tests syntax and language rules, not query performance, execution plans, data modelling decisions or working with messy real data. It also doesn't cover analytic window functions in depth, which interviewers use constantly. Live coding rounds expose whether you can write correct SQL quickly, explain it, and verify the result, so practise on realistic schemas.

Pay:Range based on Indeed's US average base pay for SQL Developer ($94,771, range about $65K-$138K, updated October 2026) and the BLS May 2025 median for database administrators ($104,620). Performance tuning, cloud data platforms, ETL tools and finance or healthcare domains push pay higher.

Still sitting the Oracle 1Z0-071?

Pass it first time and walk into the interview with the credential on your CV. ExamCert AI has exam-style Oracle 1Z0-071 questions with an explanation for every option.

Practise on ExamCert AIFree Oracle 1Z0-071 practice test

FAQ

What SQL will I be tested on in a developer interview?

Almost always joins, GROUP BY with HAVING, subqueries and window functions like ROW_NUMBER, RANK and running totals. Many interviews add NULL edge cases, deduplication, date handling and a question about indexes or execution plans. Practise writing queries without autocomplete, explain your reasoning out loud, and always mention how you'd check the answer is right.

Does it matter if I learned Oracle SQL but the job uses SQL Server or PostgreSQL?

Core SQL transfers well, and most interviewers care more about correct logic than dialect. Know the main differences: row limiting (FETCH FIRST in Oracle and standard SQL, TOP in SQL Server, LIMIT in PostgreSQL and MySQL), string concatenation, date functions, empty string versus NULL, and upsert syntax. Saying 'in Oracle I'd do this, in SQL Server it's this' is a strength.

How much database administration do SQL developers need to know?

You won't usually manage backups or servers, but you should understand indexes, statistics, execution plans, locking and transactions well enough to write code that performs and doesn't block others. Knowing when to involve a DBA, for example after a bad committed change or a plan regression, is also something interviewers look for.

Are window functions on the 1Z0-071 exam?

The 1Z0-071 topic list focuses on core SQL: SELECT, functions, grouping, joins, subqueries, set operators, DML, DDL and views. Analytic window functions are not a listed topic, but they are among the most common interview questions for SQL roles. If you've only studied for the exam, spend extra time on ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD and windowed SUM.

Should I expect a take-home SQL test?

Many companies use an online assessment or take-home with a small schema and five to ten questions, scored on correctness and sometimes style. Read every question carefully, handle NULLs and ties explicitly, comment any assumptions, and test against the data provided. A short note explaining your approach helps reviewers and often comes up in the follow-up interview.

Sources

Figures on this page come from Oracle and the other primary sources below:

Checked November 4, 2026. Fees, outlines and eligibility rules change — confirm with Oracle before you book.