Modern SQL

modern-sql.com · Personal blog · on HN since 2015

Markus Winand explains modern SQL features and standards, such as window functions, WITH queries, NULL handling, and what each SQL release added.

What HN saysHN commenters recommend it as a fantastic resource for leveling up in SQL, one said they learned many useful tricks from it.
71HN people shared it
50linked it in comments
62stories submitted
1.3Kstory points
4 months agolast shared
2015people per year2026

Most-shared posts

  1. 1
    Modern SQL
    26 people · 11 points · first shared 2016 · 1 comments on HN
  2. 2
    Three-Valued Logic
    7 people · 140 points · first shared 2017 · 72 comments on HN
  3. 3
    What's New in SQL:2016
    7 people · 4 points · first shared 2017 · discussion on HN
  4. 4
    Pivot – Rows to Columns
    6 people · 156 points · first shared 2016 · 40 comments on HN
  5. 5
    Literate SQL
    5 people · 293 points · first shared 2015 · 95 comments on HN
  6. 6
    Null in SQL: Indicating the Absence of Data
    4 people · 3 points · first shared 2017 · discussion on HN
  7. 7
  8. 8
    Modern SQL: With – Organize Complex Queries
    3 people · 165 points · first shared 2015 · 61 comments on HN
  9. 9
    The SQL filter clause: selective aggregates
    3 people · 138 points · first shared 2016 · 47 comments on HN
  10. 10
    SQLite in 2018: A state of the art SQL dialect
    3 people · 9 points · first shared 2019 · discussion on HN
  11. 11
    Free Resources Around the SQL Standard
    3 people · 1 points · first shared 2019 · discussion on HN
  12. 12
    One Giant Leap for SQL: MySQL 8.0 Released
    2 people · 136 points · first shared 2018 · 152 comments on HN
  13. 13
    Modern SQL
    2 people · 9 points · first shared 2015 · discussion on HN
  14. 14
    PostgreSQL Standard SQL Gap Analysis
    2 people · 6 points · first shared 2018 · discussion on HN
  15. 15

What HN people wrote when they linked it

qohen · 2026-06-04
A couple of sites worth checking out to level up, both by Markus Winand: https://modern-sql.com/ https://use-the-index-luke.com/
wenc · 2022-03-09
Jennifer Widom’s Databases course is great https://online.stanford.edu/courses/soe-ydatabases-databases Otherwise SQL is best learned by solving problems and googling when you’re stuck. Most developers only need a few SQL constructs like SELECT, WHERE, WITH, JOIN, INSERT, CREATE and GROUP BY. Most devs learn and forget because they don’t use SQL very often. It’s too bad because the relational data structure (or more generally the table) is a super useful abstraction and often much more powerful than lists and dicts. Data analysts need a few more like OVER (PARTITION BY) and maybe PIVOT/UNPIVOT. Data engineers of course need many more specifically those related to database object manipulation, and stuff around performance like INDEX. Really advanced SQL experts do stuff like this. https://modern-sql.com/
simonw · 2021-08-13
Markus's site https://modern-sql.com/ is fantastic, I've learned a ton of useful tricks from it.
crazysmoove · 2019-05-09
I think Oracle does. My impression is that PostgreSQL sort-of "invented" JSON support in the db, then Oracle (and probably others) added JSON support with a different syntax, and then Oracle got their version defined into the SQL standard. I'm half-guessing here, but it's based on what I've gleaned from Markus Winand's [0] excellent compatibility tables in his slides [1]. [0] https://modern-sql.com/ [1] https://modern-sql.com/slides/ModernSQL-2019-05-08.pdf, for example (Edited for formatting.)
MarkusWinand · 2019-02-13
Since you ased about indexing in particular, here is my site about indexing: https://use-the-index-luke.com/ You might also want to follow my other project: https://modern-sql.com/
mwexler · 2018-02-05
Markus is modest; he is the author of the top post, and imho is up with Joe Celko in offering great techniques to use SQL effectively (both at http://modern-sql.com/ as above and http://use-the-index-luke.com/). I'm a fan.
Dangeranger · 2016-11-17
The list is missing http://use-the-index-luke.com and http://modern-sql.com which are some of the very best resources out there for SQL in general. It also misses https://www.pgexercises.com which is an amazing resource for learning the specifics of PostgreSQL in particular.
adilkhash · 2021-01-06
i would also recommend the wonderful https://modern-sql.com/
ndriscoll · 2023-11-17
https://modern-sql.com/ has some info about more recent additions to SQL to make life easier/write higher level queries. Once you have the basics of SQL down (like how to write a query), you want to understand what the database actually does with your queries, so you can predict what the query plan "ought to be"/what you want, and you can read the query plans to try to understand why you did or didn't get the plan you expect. https://use-the-index-luke.com/ And then once you understand the fundamentals, your database's manual is the place to go. Especially different index types (including their internals!) and what kinds of queries they support. The above link goes into depth about b-trees, but there are other types, and you can use b-trees as a reference point to contrast with others. https://www.postgresql.org/docs/current/index.html
Twisell · 2023-10-16
Please elaborate because that sentence make barely no sense for modern SQL engine such as PostgreSQL. A good ressource to start exploring would be this site with compare features between vendors: https://modern-sql.com/
sam_goody · 2023-06-02
And even so, Postgres is closer to the spec than Oracle is. (Based on perusing https://modern-sql.com)
ainar-g · 2022-10-27
https://modern-sql.com/ is another site with compatibility graphs.
nalgeon · 2021-03-12
Markus Winand is doing something like that at https://modern-sql.com/. But it's not nearly as extensive as caniuse.com
0x54MUR41 · 2021-01-05
Markus Winand [0]. He is the creator behind "Use the index, Luke!" [1] and "Modern SQL" [2]. [0]: https://twitter.com/MarkusWinand [1]: https://use-the-index-luke.com/ [2]: https://modern-sql.com/
taffer · 2019-09-18
> Is there a caniuse.com for SQL? Not exactly the same, but: https://modern-sql.com/
tannhaeuser · 2019-03-01
According to [1], ISO/IEC 9075:2016 specifies JSON functionality in ISO SQL, though I don't have access to it/didn't buy the standard text. I also don't know whether Postgres etc. is designed to follow the standard, as Postgres' implementation predates it, but would expect sqlite to. [1]: https://modern-sql.com/blog/2017-06/whats-new-in-sql-2016
boshomi · 2019-02-15
@MarkusWindand: Thank you for the Websites [1],[2],[3] and the book »SQL Performance Explained«[4]. [1] https://modern-sql.com/ [2] https://use-the-index-luke.com/ [3] https://db-engines.com/ [4] https://www.amazon.de/SQL-Performance-Explained-Everything-performance…
adambyrtek · 2018-10-07
Really good introduction to some of the more "modern" features: https://modern-sql.com/
mamcx · 2017-10-05
This have help me in discover extra powers of sql: http://modern-sql.com/ And http://use-the-index-luke.com/
threepipeproblm · 2017-05-02
Possibly relevant: Modern SQL is a good resource, by Markus Winand, on the newer aspects of the language. http://modern-sql.com/
mhotchen · 2017-01-17
He's started work on his next book[0] which looks to be interesting. [0] http://modern-sql.com/
zX41ZdbW · 2023-02-10
It's worth noting that ClickHouse supports both the standard SQL and the extensions. For example, the standard SQL way to write filtered aggregates is: SELECT avg(number) FILTER (WHERE number > 50) FROM numbers(100) See https://modern-sql.com/feature/filter But it is only supported by SQLite, PostgreSQL, and ClickHouse. While ClickHouse also provides a shorthand: SELECT avgIf(number, number > 50) FROM numbers(100) The same for DISTINCT: SELECT avg(DISTINCT number) SELECT avgDistinct(number) Why filtered aggregates are important? - They allow to implement the "segment comparison" feature in web analytics services. WITH Region = 'us' AS segment1, Browser = 'Chrome' AS segment2 SELECT uniqIf(UserID, segment1), uniqIf(UserID, segment2) WHERE segment1 OR segment2 Most of the existing web analytics services are using ClickHouse: CloudFlare Analytics, Microsoft Clarity, Plausible Analytics, PostHog, Splitbee...
gregw2 · 2026-04-29
You raise a good point. Skimming the original article, I didn't really understand why the author didn't discuss "WITH" CTEs (for SQL newbies, common table expressions, see https://modern-sql.com/feature/with ) as alternative composition mechanisms. Or even SQL views. But your ergonomics comment makes sense to me.
snthpy · 2026-03-11
Another thing you are apparently missing is deterministic ordering for tied elements: https://modern-sql.com/blog/2026-03/order-equivalence-over-clause
reshlo · 2025-01-29
`CUME_DIST() OVER (ORDER BY column)` https://modern-sql.com/caniuse/cume_dist
atombender · 2025-01-11
ANSI SQL has had IS [NOT] UNKNOWN since SQL:1999 [1]. It's an optional feature that some databases don't support. Postgres, MySQL, and MSSQL do support it. [1] https://modern-sql.com/concept/three-valued-logic#compatibility
otteromkram · 2025-01-10
There's another good, technical write-up on NULL behavior in SQL at modern-sql.com https://modern-sql.com/concept/null (Note: I am not affiliated with that bloh/website in any way, shape, or form.)
Recursing · 2025-01-10
Surprised that this doesn't mention "IS DISTINCT FROM" ( https://modern-sql.com/caniuse/is-distinct-from ) (Although in rare cases that is even weirder: https://stackoverflow.com/a/58998043 )
dveeden2 · 2024-08-21
The good thing here is that other databases like MySQL, TiDB, SQLite etc also support this. so this. And even recursive CTEs are well supported. https://modern-sql.com/caniuse/with_(non-recursive,_top_level)

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close