Link: https://adventofsql.com/challenges/2

Solution: https://github.com/kiran-4444/advent-of-sql-2024/blob/main/day-2.sql

This seemed straightforward at first but required a little more thought. I had to look at the chr function, which converts ASCII values to characters.

Then I looked at the UNION ALL query to horizontally stack two tables.

Finally, I looked at the string_agg function that joins all the values of a column into a string.

My solution is long as I’m not aware of CTEs. I tried asking ChatGPT and Claude to modify my query using CTE, but I didn’t completely understand the results and will probably spend tomorrow looking into CTEs.