Black Friday: Save 40% on any Aced plan. Our only sale of the year!
Skip to main content

20+ PostgreSQL Interview Questions and Answers (2026)

Data Science
Aced TeamAced Team • Published

PostgreSQL interview questions come from 2 kinds of rounds: data screens that run your SQL in PostgreSQL, and loops that ask how the engine works. In 2026, a Meta data engineer screen ran in PostgreSQL, and an Anthropic data scientist SQL round required PostgreSQL queries that pass test cases. Each of the 20 questions below comes with a worked answer tested in PostgreSQL, plus the syntax that changes when a screen runs MySQL.

✅
How we built this guide: We drew on 11 reports of 2025 and 2026 interviews at 5 companies. They come from member write-ups, our question bank, and public reports. Some reports name the dialect a screen ran, and others supply the Meta questions. Schemas follow what candidates remembered, and we filled in the gaps. Every query ran in PostgreSQL 15 on our own sample data, and every PostgreSQL behavior is checked against the PostgreSQL 18 documentation.

PostgreSQL interview questions at a glance

Meta's 2026 data engineer screens produced 3 of these questions, and one covers a topic from a 2026 Revolut software engineer round. The rest are PostgreSQL behavior that breaks answers written from another dialect.

QuestionWhat it tests
Count each user's overdue library booksFILTER, COALESCE, NULL comparison
Top earner in each departmentDISTINCT ON vs. RANK
Author statistics in one rowFILTER, integer division, regex
Why does SUM(is_active) fail?Boolean type, FILTER
Monthly revenue, including empty monthsgenerate_series, half-open ranges
What does subtracting 2 dates return?Date and interval arithmetic
Rolling 7-day average with missing daysRANGE frames with an interval
Users who came back after 7 days awayLAG, date subtraction
Why does NOT IN return no rows?NULL logic and NOT EXISTS
Why does 7 / 2 return 3?Integer division, round()
Why does WHERE status = "open" fail?Quoting, case sensitivity
How do you query a JSONB column?->, ->>, @>, GIN
How do you write an upsert?INSERT ... ON CONFLICT
Does a CTE change the query plan?CTE inlining, MATERIALIZED
How do you find out why a query is slow?EXPLAIN ANALYZE
Why isn't PostgreSQL using your index?Expression indexes
Which index type fits which query?B-tree, GIN, BRIN and others
What is MVCC, and why does PostgreSQL need VACUUM?Row versions, VACUUM
Which isolation levels does PostgreSQL support?Read Committed, Repeatable Read
How does Amazon Redshift differ from PostgreSQL?Columnar storage, constraints

Which SQL interviews run in PostgreSQL

Meta's data engineer technical screen ran in PostgreSQL and Python in 2026. In a 2025 screen, each language got 30 minutes. Its SQL questions moved from GROUP BY, HAVING, and joins to window functions and CTEs, then LAG and LEAD. In that screen, you could also ask the interviewer about PostgreSQL vs. MySQL syntax differences.

These 2025 and 2026 rounds named the dialect their editor runs:

Company and roleRound and dateDialectFormat
Anthropic, data scientistTechnical screen, 2026PostgreSQL3 to 4 collaborative SQL exercises at medium to hard level, which you run and debug
Anthropic, data scientistOnsite SQL round, 2026PostgreSQLAbout 4 to 5 questions, and each query has to pass test cases
Revolut, software engineerTechnical screen, 2026PostgreSQLQuestions on PostgreSQL tuning and your hands-on work
DoorDash, data engineerHackerRank screen, 2026MySQL only4 SQL questions graded by test cases, where PostgreSQL syntax didn't compile
Amazon, BI engineerOnline assessment, 2025MySQL15 multiple-choice SQL concept questions in MySQL syntax

When the editor runs your query, a dialect slip costs minutes you can't recover. Ask the recruiter which database the editor runs. In a 2026 Anthropic data scientist SQL round, the questions weren't difficult, and every query had to run. Practice PostgreSQL syntax until you don't need to look it up.

Questions from Meta's data engineer screens

Meta's 2026 data engineer screens used library and bookstore schemas, with several short questions on each. One 2026 screen ran in PostgreSQL, and the answers here use PostgreSQL features that save typing. For every Meta question with its schema, see Meta SQL interview questions.

1. Count each user's overdue library books

Meta, data engineer technical screen, 2026

You have users, books, and checkouts with checkout_date, due_date, and return_date. Count each user's books that weren't returned by the due date, and return the username and the count.

SQL
SELECT u.username, COUNT(c.checkout_id) FILTER ( WHERE COALESCE(c.return_date, CURRENT_DATE) > c.due_date ) AS overdue_books FROM users u LEFT JOIN checkouts c ON c.user_id = u.user_id GROUP BY u.username ORDER BY overdue_books DESC, u.username;

COALESCE treats a book that's still out as returned today. One comparison then covers late returns and unreturned books. Comparing a NULL return_date with a date returns NULL, and a plain return_date > due_date filter drops every book that's still out.

On a 4-user sample, the plain filter found 1 overdue book for ana and listed only 2 users. The query above found ana's 2 and kept the 2 users with 0. `FILTER` counts only the rows that match, which lets the LEFT JOIN keep everyone. Ask whether a book due today counts as overdue: the query above says no.

2. Top earner in each department

Meta, data engineer technical round, 2026

The tables are employees (id, first_name, last_name, salary, department_id) and departments (id, name). Return the highest-paid employee in each department, ordered by department name.

SQL
SELECT DISTINCT ON (d.name, d.id) d.name AS department_name, e.first_name, e.last_name, e.salary FROM employees e JOIN departments d ON d.id = e.department_id ORDER BY d.name, d.id, e.salary DESC, e.id;

`DISTINCT ON` keeps the first row of each group in the query's sort order. ORDER BY decides which employee you get. Its expressions must match the leftmost ORDER BY expressions, or PostgreSQL rejects the query. Including d.id keeps 2 departments with the same name apart.

In the sample, 2 Analytics employees tie at 180,000, and DISTINCT ON returned only the one with the lower id. If the interviewer wants every tied employee, rank the rows:

SQL
SELECT department_name, first_name, last_name, salary FROM ( SELECT d.name AS department_name, e.first_name, e.last_name, e.salary, RANK() OVER (PARTITION BY d.id ORDER BY e.salary DESC) AS rnk FROM employees e JOIN departments d ON d.id = e.department_id ) ranked WHERE rnk = 1 ORDER BY department_name, last_name;

The RANK version returned both Analytics employees. MySQL's SELECT syntax doesn't include DISTINCT ON. In a MySQL screen, use RANK or ROW_NUMBER.

3. Author statistics in one row

Meta, data engineer phone screen, 2026

The schema has books, authors (with website_url), transactions, and members. Return one row with the number of authors, the percentage whose website URL contains ".com", and the percentage who have never sold a book.

SQL
WITH sold_authors AS ( SELECT DISTINCT b.author_id FROM books b JOIN transactions t ON t.book_id = b.book_id ) SELECT COUNT(*) AS unique_authors, ROUND(100.0 * COUNT(*) FILTER (WHERE a.website_url LIKE '%.com%') / COUNT(*), 1) AS pct_dot_com, ROUND(100.0 * COUNT(*) FILTER (WHERE s.author_id IS NULL) / COUNT(*), 1) AS pct_never_sold FROM authors a LEFT JOIN sold_authors s ON s.author_id = a.author_id;

Reduce sales to one row per author before the join. The outer query then keeps one row per author, and never-sold authors get a NULL match. Each FILTER counts its own condition in the same pass. An author with no URL fails the LIKE test, which counts them as not ".com".

Write 100.0: integer division in PostgreSQL truncates, and 100 * 3 / 7 returns 42. Ask what ".com" means. In the sample, LIKE '%.com%' also matched https://dia.community.org, and the regex website_url ~ '\.com(/|$)' matched only the 2 URLs with a .com domain.

PostgreSQL syntax questions

PostgreSQL syntax questions test the features MySQL lacks and the defaults that differ between the 2 databases. Each answer ran on sample data in PostgreSQL, and the comments show the output or the error message.

4. Why does SUM(is_active) fail, and what do you write?

An accounts table has plan and a boolean is_active column. Count active accounts per plan:

SQL
SELECT SUM(is_active) FROM accounts; -- ERROR: function sum(boolean) does not exist SELECT plan, COUNT(*) AS accounts, COUNT(*) FILTER (WHERE is_active) AS active, ROUND(AVG(is_active::int), 2) AS active_rate FROM accounts GROUP BY plan ORDER BY plan;

PostgreSQL's boolean is its own type, and `sum()` doesn't accept a boolean. Count true rows with FILTER, or cast with ::int and then sum or average. MySQL's `BOOLEAN` is a synonym for `TINYINT(1)`, and SUM(is_active) runs there.

Decide what a NULL flag means before you average. AVG(is_active::int) skips NULLs: the free plan scored 0.50 with 1 active account out of 3. If NULL means inactive, AVG(COALESCE(is_active, false)::int) returns 0.33. COUNT(is_active) counts false rows too, which makes it the wrong tool here.

5. Monthly revenue, including months with no orders

The orders table has order_id, customer_id, order_ts, and amount. Return revenue for each month from January to April, with 0 for months without orders.

SQL
SELECT m.month::date AS month, COALESCE(SUM(o.amount), 0) AS revenue FROM generate_series( TIMESTAMP '2026-01-01', TIMESTAMP '2026-04-01', INTERVAL '1 month' ) AS m(month) LEFT JOIN orders o ON o.order_ts >= m.month AND o.order_ts < m.month + INTERVAL '1 month' GROUP BY m.month ORDER BY m.month;

Grouping by date_trunc('month', order_ts) alone returns only months with orders. February disappears. The `generate_series` call builds the calendar, and the LEFT JOIN with COALESCE gives February a 0.

Join timestamps on a half-open range. BETWEEN '2026-03-01' AND '2026-03-31' stops at midnight on March 31. It dropped a 6:30 PM order and returned 200 for March, and the half-open range returned 250.

6. What does subtracting 2 dates return in PostgreSQL?

In PostgreSQL, date - date returns an integer number of days, and timestamp - timestamp returns an interval. Adding an integer to a date returns a date, and adding an interval returns a timestamp, as the date/time operator table lists.

SQL
SELECT DATE '2026-03-15' - DATE '2026-03-01' AS days, -- 14 (integer) TIMESTAMP '2026-03-15 12:00' - TIMESTAMP '2026-03-01 00:00' AS gap, -- 14 days 12:00:00 (interval) EXTRACT(EPOCH FROM TIMESTAMP '2026-03-15 12:00' - TIMESTAMP '2026-03-01 00:00') / 86400 AS gap_days; -- 14.5

To get the days from signup to first order, cast the timestamp to a date first, or the result is an interval:

SQL
SELECT c.customer_id, MIN(o.order_ts)::date - c.signup_date AS days_to_first_order FROM customers c JOIN orders o ON o.customer_id = c.customer_id GROUP BY c.customer_id, c.signup_date ORDER BY c.customer_id;

MySQL returns the same day count with DATEDIFF(end_date, start_date).

7. Write a 7-day rolling average when some days have no rows

The daily_sales table has one row per day with revenue, and days without sales are missing. Return each day's average over the last 7 calendar days.

SQL
SELECT day, revenue, ROUND(AVG(revenue) OVER ( ORDER BY day ROWS BETWEEN 6 PRECEDING AND CURRENT ROW), 1) AS avg_last_7_rows, ROUND(AVG(revenue) OVER ( ORDER BY day RANGE BETWEEN INTERVAL '6 days' PRECEDING AND CURRENT ROW), 1) AS avg_last_7_days FROM daily_sales ORDER BY day;

ROWS BETWEEN 6 PRECEDING counts 7 rows, and with gaps those rows span more than 7 calendar days. RANGE with an interval offset keeps the frame to 7 calendar days. With March 4 and 5 missing from the sample, the 2 versions returned 161.4 and 184.0 on March 10.

The RANGE version averages only the days that had sales. If a missing day should count as 0, join to a generate_series calendar first, as in question 5. MySQL 8.4 accepts the same frame as RANGE BETWEEN INTERVAL 6 DAY PRECEDING AND CURRENT ROW.

8. Find users who came back after 7 or more days away

The logins table has user_id and login_ts. Return each user and date where the user logged in after 7 or more days without a login.

SQL
WITH days AS ( SELECT DISTINCT user_id, login_ts::date AS login_date FROM logins ), gaps AS ( SELECT user_id, login_date, login_date - LAG(login_date) OVER ( PARTITION BY user_id ORDER BY login_date ) AS days_since_last FROM days ) SELECT user_id, login_date AS returned_on, days_since_last FROM gaps WHERE days_since_last >= 7 ORDER BY user_id, login_date;

PostgreSQL doesn't allow window functions in WHERE and returns "window functions are not allowed in WHERE". Compute the gap in a CTE, then filter it.

Reduce the data to one row per user per day first, or 2 logins on the same day produce a gap of 0. Subtracting 2 dates gives whole days, which lets days_since_last compare directly with 7.

9. Why does NOT IN return no rows?

You want shoppers who aren't on a blocklist, and the blocklist contains a NULL:

SQL
SELECT shopper_id FROM shoppers WHERE shopper_id NOT IN (SELECT shopper_id FROM blocklist); -- (0 rows) SELECT s.shopper_id FROM shoppers s WHERE NOT EXISTS ( SELECT 1 FROM blocklist b WHERE b.shopper_id = s.shopper_id ) ORDER BY s.shopper_id; -- 1, 3, 4

When a shopper isn't in the subquery and the subquery contains a NULL, `NOT IN` evaluates to NULL, and WHERE drops every row. NOT EXISTS checks for a matching row, and the NULL doesn't affect that check.

The same logic breaks <> on nullable columns. WHERE region <> 'US' skipped the shopper with no region and returned 1 row. IS DISTINCT FROM treats NULL as a comparable value and returned 2.

10. Why does 7 / 2 return 3?

Dividing 2 integers in PostgreSQL truncates toward zero: 7 / 2 returns 3, and -7 / 2 returns -3. Cast one side to numeric before dividing. MySQL's `/` returns 3.5000 for the same expression.

SQL
SELECT ad_id, clicks / impressions AS ctr_truncated, -- 0, 0, 0 ROUND(clicks::numeric / impressions, 3) AS ctr -- 0.075, 0.083, 0.000 FROM ad_stats ORDER BY ad_id; SELECT ROUND(AVG(clicks)::float8, 2) FROM ad_stats; -- ERROR: function round(double precision, integer) does not exist

PostgreSQL's round() takes a decimal-places argument only for numeric values. Because avg() of an integer column already returns numeric, ROUND(AVG(clicks), 2) works without a cast.

11. Why does WHERE status = "open" fail?

A tickets table stores status values such as 'open' and 'Open'. The first query fails:

SQL
SELECT * FROM tickets WHERE status = "open"; -- ERROR: column "open" does not exist SELECT COUNT(*) FROM tickets WHERE status = 'open'; -- 1 SELECT COUNT(*) FROM tickets WHERE status ILIKE 'open'; -- 2

PostgreSQL reads double quotes as an identifier, which makes "open" a column name. String literals take single quotes. MySQL accepts double-quoted strings unless the ANSI_QUOTES SQL mode is on, and the default mode leaves it off.

In PostgreSQL, string comparison is case-sensitive: 'open' doesn't match 'Open'. Use `ILIKE` or lower() to ignore case. MySQL's default collation compares strings case-insensitively. Unquoted identifiers fold to lower case, which is why SELECT * FROM DailyStats fails after CREATE TABLE "DailyStats" with "relation "dailystats" does not exist".

12. How do you query a JSONB column?

The events table has a payload jsonb column such as {"type": "purchase", "amount": 42.5, "device": {"os": "ios"}}. Return purchase revenue by operating system.

SQL
SELECT payload -&gt; 'device' -&gt;&gt; 'os' AS os, SUM((payload -&gt;&gt; 'amount')::numeric) AS revenue FROM events WHERE payload @&gt; '{"type": "purchase"}' GROUP BY 1 ORDER BY 1; -- android | 18 -- ios | 42.5

The `->` operator returns jsonb and `->>` returns text. Cast the ->> result before doing math. The @> operator tests containment, and the default GIN operator class for jsonb supports it. On a 100,000-row version of the table, a GIN index on payload produced a Bitmap Index Scan for a selective @> filter.

To return one row per item in an array, expand it with jsonb_array_elements:

SQL
SELECT e.event_id, item -&gt;&gt; 'sku' AS sku FROM events e LEFT JOIN LATERAL jsonb_array_elements(e.payload -&gt; 'items') AS item ON true ORDER BY e.event_id, sku;

The LEFT JOIN LATERAL ... ON true keeps events that have no items, with a NULL sku. MySQL's JSON operators take a path, as in payload->>'$.device.os'.

13. How do you write an upsert in PostgreSQL?

Load a daily batch into daily_user_stats (user_id, day, events), and add to the count when the row already exists.

SQL
INSERT INTO daily_user_stats (user_id, day, events) VALUES (1, '2026-06-01', 3), (2, '2026-06-01', 7) ON CONFLICT (user_id, day) DO UPDATE SET events = daily_user_stats.events + EXCLUDED.events;

EXCLUDED holds the row you tried to insert, and the table name refers to the existing row. In the sample, user 1's count went from 5 to 8, and user 2 was inserted with 7.

The conflict target has to match a unique index or constraint. Without one, PostgreSQL raises "there is no unique or exclusion constraint matching the ON CONFLICT specification". MySQL writes the same operation as INSERT ... ON DUPLICATE KEY UPDATE.

PostgreSQL performance and internals questions

A 2026 Revolut software engineer screen asked about PostgreSQL tuning. For that loop, also prepare consistency levels and PostgreSQL internals. Answer engine questions with a query plan or a demonstration. The plans in this section come from sample tables of 100,000 to 200,000 rows, and your own timings will differ.

14. Does a CTE change the query plan?

In PostgreSQL 12 and later, a CTE that's referenced once and is free of side effects is folded into the main query. The planner then treats it like a subquery. In a test on a 200,000-row table, a CTE filtered on user_id used the user_id index.

SQL
EXPLAIN WITH v AS MATERIALIZED (SELECT * FROM page_views) SELECT * FROM v WHERE user_id = 42; -- CTE Scan on v -- Filter: (user_id = 42) -- CTE v -- -&gt; Seq Scan on page_views

MATERIALIZED forces PostgreSQL to compute the CTE first, and the plan switched to a full scan. A CTE referenced more than once is computed separately by default, and NOT MATERIALIZED folds it in anyway. If an interviewer asks you to rewrite a single-use CTE as a subquery for speed, explain that the plan is the same.

15. How do you find out why a PostgreSQL query is slow?

Revolut, software engineer technical screen, 2026 (tuning topic)

Run EXPLAIN ANALYZE and read the plan from the innermost node out. EXPLAIN alone shows the estimated plan, and ANALYZE runs the query and adds actual row counts and times.

SQL
EXPLAIN ANALYZE SELECT COUNT(*) FROM page_views WHERE user_id = 42; -- Seq Scan on page_views (... rows=10 ...) -- Filter: (user_id = 42) -- Rows Removed by Filter: 199990 -- Execution Time: 9.925 ms CREATE INDEX page_views_user_id_idx ON page_views (user_id); -- Same query after the index: -- Bitmap Heap Scan on page_views (... rows=10 ...) -- -&gt; Bitmap Index Scan on page_views_user_id_idx -- Execution Time: 0.075 ms

A sequential scan that removes 199,990 rows to return 10 points to a missing index. Compare estimated rows with actual rows at each node. A large gap often means the planner's statistics are stale, and ANALYZE refreshes them.

EXPLAIN ANALYZE executes the statement. For an UPDATE or DELETE, wrap it in BEGIN and ROLLBACK, as the PostgreSQL docs recommend. In the test, a rolled-back EXPLAIN ANALYZE DELETE left all 10 rows in place. In PostgreSQL 18, the same plan also shows buffer counts and prints actual rows with 2 decimal places.

16. Why isn't PostgreSQL using your index?

A function on the indexed column blocks a plain index. An index on email doesn't serve WHERE lower(email) = '...', and an index on the expression does:

SQL
CREATE INDEX app_users_email_idx ON app_users (email); EXPLAIN SELECT user_id FROM app_users WHERE lower(email) = '[email protected]'; -- Seq Scan on app_users CREATE INDEX app_users_lower_email_idx ON app_users (lower(email)); EXPLAIN SELECT user_id FROM app_users WHERE lower(email) = '[email protected]'; -- Bitmap Heap Scan on app_users -- -&gt; Bitmap Index Scan on app_users_lower_email_idx

A leading wildcard such as LIKE '%[email protected]' produced a sequential scan even with the expression index in place. For a multicolumn B-tree, PostgreSQL is most efficient when the query constrains the leading columns.

17. Which PostgreSQL index type fits which query?

CREATE INDEX builds a B-tree unless you name another index type with USING. The main types:

Index typeWhat it handlesUse it for
B-treeEquality and range comparisons on data that can be sortedMost WHERE, JOIN, and ORDER BY columns
HashEquality comparisons onlyExact-match lookups
GiSTA framework for many search strategies, such as 2-D geometric typesGeometric data
GINValues with several components, such as arrays and jsonbjsonb containment and array membership
BRINSummaries of consecutive physical block rangesLarge tables whose values follow physical row order

PostgreSQL also has SP-GiST, for structures such as quadtrees, k-d trees, and radix trees. In an interview, name the default first and then the case that needs something else. For jsonb filters, that's GIN, and for a large append-only table filtered by time, it's BRIN.

18. What is MVCC, and why does PostgreSQL need VACUUM?

PostgreSQL's MVCC gives each statement a snapshot of the data. Reading never blocks writing, and writing never blocks reading. An UPDATE writes a new row version and leaves the old version in place until VACUUM removes it.

SQL
SELECT ctid, xmin, balance FROM balances; -- (0,1) | 9492 | 100 UPDATE balances SET balance = 90 WHERE id = 1; SELECT ctid, xmin, balance FROM balances; -- (0,2) | 9493 | 90 VACUUM (VERBOSE) balances; -- tuples: 1 removed, 1 remain, 0 are dead but not yet removable

The new ctid shows the updated row in a new physical slot, and the new xmin is the updating transaction's ID. Autovacuum runs VACUUM and ANALYZE automatically, and VACUUM also protects old data from transaction ID wraparound. A table with heavy updates and slow vacuuming grows with dead rows. Name dead rows when an interviewer asks about bloat.

19. Which isolation levels does PostgreSQL support, and which is the default?

PostgreSQL supports Read Committed, Repeatable Read, and Serializable, and Read Committed is the default. You can request Read Uncommitted, and PostgreSQL runs it as Read Committed. PostgreSQL's Repeatable Read also prevents phantom reads.

Under Repeatable Read, updating a row that another transaction changed and committed fails. In a 2-session test, session B committed while session A was mid-transaction:

SQL
-- Session A BEGIN ISOLATION LEVEL REPEATABLE READ; SELECT balance FROM wallet WHERE id = 1; -- 100 -- Session B, meanwhile: -- UPDATE wallet SET balance = balance - 20 WHERE id = 1; -- Session A UPDATE wallet SET balance = balance - 10 WHERE id = 1; -- ERROR: could not serialize access due to concurrent update

Under Read Committed, session A's update applied to B's committed value, and the final balance was 70. The error has SQLSTATE 40001, and your application has to retry the transaction. MySQL's InnoDB defaults to Repeatable Read.

20. How does Amazon Redshift differ from PostgreSQL?

Amazon Redshift is based on PostgreSQL, and it leaves out PostgreSQL features suited to small-scale transaction processing. Name these differences:

Tie each difference to a workload. Redshift fits large scans and aggregations over many rows, and PostgreSQL fits transactional reads and writes of single rows with enforced keys.

PostgreSQL vs. MySQL: the syntax that changes

If your screen runs MySQL, as a DoorDash screen and an Amazon assessment did, switch these PostgreSQL forms to their MySQL 8.4 versions:

TaskPostgreSQLMySQL 8.4
String literal'open' ("open" is a column)'open' or "open"
Integer division7 / 2 returns 37 / 2 returns 3.5000
Count true flagsCOUNT(*) FILTER (WHERE flag)SUM(flag)
First row per groupDISTINCT ON or ROW_NUMBER()ROW_NUMBER()
Group by monthdate_trunc('month', d)DATE_FORMAT(d, '%Y-%m-01')
Days between datesend_date - start_dateDATEDIFF(end_date, start_date)
Add 7 daysd + INTERVAL '7 days'DATE_ADD(d, INTERVAL 7 DAY)
Join values per groupSTRING_AGG(x, ',' ORDER BY x)GROUP_CONCAT(x ORDER BY x SEPARATOR ',')
Full outer joinFULL OUTER JOINLEFT JOIN UNION RIGHT JOIN
UpsertON CONFLICT (...) DO UPDATEON DUPLICATE KEY UPDATE
Compare 'abc' = 'ABC'FalseTrue with the default collation
NULLs in ORDER BY x ascendingSorted lastSorted first
Default isolation levelRead CommittedRepeatable Read

MySQL's join syntax doesn't include FULL OUTER JOIN, and its aggregates don't accept a FILTER clause. In a MySQL screen, write SUM(CASE WHEN ... THEN 1 ELSE 0 END) for conditional counts and ROW_NUMBER() for first-row-per-group questions. PostgreSQL sorts NULLs last in ascending order, and MySQL sorts them first. MySQL's ORDER BY syntax doesn't accept NULLS LAST, which leaves ORDER BY x IS NULL, x as the way to put NULLs last.

Practice PostgreSQL interview questions

Practice in the dialect your screen runs:

Frequently asked questions

Do SQL interviews use PostgreSQL or MySQL?

SQL interviews use whichever database the company's editor runs, and both appear in 2025 and 2026 screens. In 2026, a Meta data engineer screen and Anthropic data scientist rounds ran PostgreSQL. A DoorDash data engineer screen and an Amazon BI engineer assessment used MySQL. Ask your recruiter which one your round uses.

Is PostgreSQL syntax different from standard SQL?

PostgreSQL supports most of the major features of SQL:2023 and adds its own extensions. DISTINCT ON and ILIKE are PostgreSQL extensions. Say you're using them, and have a portable version ready.

What PostgreSQL topics should a data engineer prepare?

For a Meta data engineer screen, prepare GROUP BY and HAVING, joins, CTEs, and window functions, including LAG and LEAD. If a loop asks about tuning, as a 2026 Revolut software engineer screen did, prepare EXPLAIN ANALYZE, indexes, MVCC, and isolation levels.

Can you use DISTINCT ON or FILTER in a SQL interview?

You can use DISTINCT ON and FILTER when the screen runs PostgreSQL. Confirm the dialect first: neither works in MySQL. If the editor runs MySQL, use ROW_NUMBER() and SUM(CASE ...).

Related Courses

Data Science Interview Prep Course

8 courses5,300 students

Land your dream data science role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates. Practice statistics, experimentation, coding, SQL, machine learning, behavioral interviews, and more.

Python Coding Questions for Data Scientists

18 lessons1,000 students

Master Python coding interviews focused on data science by exploring advanced data manipulation with Pandas and conducting statistical analysis and experiments. Gain proficiency in handling and transforming datasets, performing thorough statistical tests, and designing experiments with Python. Perfect for those looking to excel in technical interviews that assess data handling and analytical skills.

Related Blog Posts

12 DoorDash SQL Interview Questions (2026)

10 days ago  •  12 min read

14 Meta SQL Interview Questions (2026)

10 days ago  •  14 min read

Data Science Interview Prep (2026 Guide)

2 months ago  •  5 min read

Top AI/ML Companies Hiring Now

2 months ago  •  3 min read
formerly Exponent

Get updates in your inbox with the latest tips, job listings, and more.

Follow Us

Products
Courses
Interview Questions
Interview Experiences
Popular articles
Guides
Coaching
For Partners
Company
Exponent Labs, LLC © 2026
Terms of Service | Privacy