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

Table of Contents
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.
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
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
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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
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.
What's the difference between UNION and UNION ALL? When does it matter?
What they are testing: Set operator semantics and their performance cost
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.
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
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.
Explain transaction isolation levels. What does Oracle do differently from other databases?
What they are testing: Concurrency anomalies and vendor-specific behaviour
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.
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
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.
How do you write an upsert in Oracle, and what are the common MERGE pitfalls?
What they are testing: Practical DML and vendor differences
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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 testThe practical task
Expect some version of this. Companies vary the details, not the shape.
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.
- Inspect the tables first: keys, row counts, NULL columns and whether order_items can have several rows per product.
- Aggregate revenue from order_items with COALESCE for NULL discounts, grouping by a truncated month with clear date bounds.
- Use DENSE_RANK or ROW_NUMBER partitioned by category for top three, and state how ties are handled.
- Find lapsed customers with NOT EXISTS or MINUS, explaining why NOT IN is risky if any value can be NULL.
- 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:
Mistakes that sink candidates
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 testFAQ
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:
- Oracle Database SQL (1Z0-071) exam - Oracle University
- SQL Developer salaries in the United States - Indeed
- Database Administrators and Architects - BLS Occupational Outlook Handbook
- Nulls - Oracle Database 19c SQL Language Reference
- Data Concurrency and Consistency - Oracle Database 19c Concepts
Checked November 4, 2026. Fees, outlines and eligibility rules change — confirm with Oracle before you book.
