SQL Mastery: Tricky PostgreSQL MCQ Practice Tests

Course Details
Test How Well You Really Know SQL
SQL looks simple until a query returns something you did not expect. Why does a filter for every status except closed skip some rows? Why does NOT IN suddenly return nothing? Why does a LEFT JOIN behave like an inner join once you add a WHERE clause? Why do two rows with the same date get the same running total? These practice tests check how well you can predict what PostgreSQL really does, one short query at a time.
What this practice test course offers:
- 200 original multiple-choice questions in 4 practice tests of 50, grouped by topic
- Short, self-contained queries you must reason about: what does the query return, what error does it raise, or what happens when two sessions run at the same time
- An explanation for every answer option, plus an overall explanation of the rule behind it
- Every query was run on PostgreSQL 19 in a fresh database, and every concurrency question in two real sessions, so every answer matches what the database really does
- Current PostgreSQL included: IGNORE NULLS for window functions and ON CONFLICT DO SELECT (19), RETURNING old and new and virtual generated columns (18), MERGE with RETURNING and NOT MATCHED BY SOURCE (17)
Topics covered:
- NULL and three-valued logic, IS DISTINCT FROM, COALESCE and NULLIF, sorting with NULLS FIRST and LAST
- Inner, outer, full, cross, natural and lateral joins, and conditions in ON versus WHERE
- Aggregates, GROUP BY, HAVING, FILTER, ROLLUP, CUBE, GROUPING and DISTINCT ON
- Scalar and correlated subqueries, EXISTS, IN, ANY and ALL, CTEs, recursive CTEs, CYCLE and SEARCH
- Window functions: ranking, lag and lead, frames with ROWS, RANGE and GROUPS, frame exclusion
- Data types: integer division, numeric versus float, rounding, casts, text, arrays, json and jsonb, dates, timestamps, time zones and intervals
- INSERT, UPDATE, DELETE, upserts with ON CONFLICT, MERGE, RETURNING, constraints, foreign keys, sequences and identity columns
- UNION, INTERSECT and EXCEPT, pagination, transactions, savepoints, isolation levels, row locks, and when an index can be used
Who should take this course?
- Developers and data analysts preparing for interviews where SQL questions come up
- Backend developers who write SQL every day and want to stop guessing about NULLs, joins and transactions
- Engineers moving to PostgreSQL from MySQL, SQL Server or Oracle who want to learn where it behaves differently
If you have never written a SELECT statement, start with an SQL fundamentals course and come back here to test yourself.
How to use the tests: take one test at a time, then read every explanation, including the ones for questions you answered correctly. Retake a test a few days later to check that the rules have stuck.
This course is independent and is not affiliated with or endorsed by the PostgreSQL Global Development Group.
Similar Courses
View More
SQL for Business Analytics & Data Analysis: 200 Practice Q&A

The Complete SQL Course: From Zero to Data Analyst

Complete Database Course: SQL, MySQL, PostgreSQL & MongoDB
