Skip to Content
0 likes
Paginate Without OFFSET Level: Intermediate

Page through a table with keyset pagination: filter on the last row you showed and add a tie-breaker. After this, a later page costs the same as the first and rows do not repeat or vanish between pages.

0 likes
Turn Rows Into Columns With FILTER Level: Intermediate

Turn one row per status into one column per status with aggregate FILTER and compare it with CASE. After this, you can build a small pivot table without an extension.

0 likes
Running Total With a Window Function Level: Intermediate

Add a running total with SUM and OVER, restart it for each group and avoid the default-frame surprise when dates tie. After this, a cumulative column is one line and not a self-join.

0 likes
Verify a CTE Rewrite Without Losing Duplicate Rows Level: Intermediate

Compare a query and its CTE rewrite in both directions with EXCEPT ALL, including duplicate and NULL rows that a plain set comparison can miss.

0 likes
Store Timestamps With Time Zone Correctly Level: Intermediate

Choose timestamptz for a moment in time and see what the session time zone and AT TIME ZONE change. After this, the same moment shows correctly for every reader.

0 likes
Top 3 Rows per Group Level: Intermediate

Rank rows inside each group and keep the first three, then decide what to do with ties and compare the LATERAL version. After this, you can pick the top rows per category and know what happens when two are equal.

0 likes
Upsert With INSERT … ON CONFLICT Level: Intermediate

Insert a row or update the one that is already there in a single statement, using the conflict target, DO NOTHING, DO UPDATE and the EXCLUDED row. After this, a repeated import updates rows instead of failing or duplicating them.