Advent of SQL
Daily database puzzles solved in PostgreSQL.

About the project
Advent of SQL is a December challenge in the style of Advent of Code, but every puzzle is a database: each day brings a PostgreSQL dump about Santa's workshop and a question that has to be answered with a query.
I solved the first twelve days of the 2024 edition in plain SQL. The puzzles go beyond joins and grouping and call for window functions, recursive queries and working with JSON and XML.
Under the hood
- Window functions such as LAG and ROW_NUMBER for comparing rows with their neighbours and ranking within groups
- A recursive CTE to walk a management hierarchy
- Querying JSONB columns and XML documents with XPath, and unnesting arrays into rows
- When
- 2024
- Type
- Personal
- Stack
- PostgreSQL