Posts for: #Sql

Techstructive Weekly #74

Week #74

It was winding down week, 2025, ending slowly, the biggest irony. The year was full of fast-paced, unprecedented models just dropping here and there. It was hard to keep up with the progress. It was getting overwhelming, no one is used to such a level of information. I was dreading with so much power in our hands. I couldn’t handle it and refrained it and thought it was better to focus on learning new things. I kept using AI tools at work, not by choice, but initially through force but then through necessity.

[]

Will Turso be the better SQLite? Interview with Glauber Costa

Will Turso be the better SQLite? Interview with Glauber Costa

Link: https://youtu.be/1JHOY0zqNBY

Context

This was a great interview. I love the mentality. If software built with community in the Linux community can sustain after almost 3 decades, then why can’t a embedded database like SQLite can? Turso is Linux Community but for SQLite (minus the toxic leadership) Pekka is a great, humble and smart leader to be leading the Turso, SQLite rewrite in Rust. I want to contribute to SQLite, but it feels I don’t know enough everytime I touch it, also I started learning SQL for this. I have gone so far and now there is no way I am turning back. I had one itch for geospatial exploration in SQLite for Mumbai city. This weekend might be the time to do it, maybe next year.

[]

Advent of SQL 2025 Day 10: Misdelivered Presents

Advent of SQL, Day 10 - Misdelivered Presents

It’s already day 10? We just need 5 more days now! Whoa! that flew by swiftly.

Let’s pull in the data.

This is the SQL for day 10 in SQLite.

DROP TABLE IF EXISTS misdelivered_presents;
DROP TABLE IF EXISTS deliveries;

CREATE TABLE deliveries (
    id INT PRIMARY KEY,
    child_name TEXT,
    delivery_location TEXT,
    gift_name TEXT,
    scheduled_at TIMESTAMP
);

CREATE TABLE misdelivered_presents (
    id INT PRIMARY KEY,
    child_name TEXT,
    delivery_location TEXT,
    gift_name TEXT,
    scheduled_at TIMESTAMP,
    flagged_at TIMESTAMP,
    reason TEXT
);

INSERT INTO deliveries (id, child_name, delivery_location, gift_name, scheduled_at) VALUES
    (1, 'Omar Q.', '45 Maple Street', 'storybook collection', '2025-12-24 21:09:00'),
    (2, 'Sofia K.', '77 Snowflake Road', 'plush reindeer', '2025-12-24 18:35:00'),
    (3, 'Mila N.', 'The Vibes', 'storybook collection', '2025-12-24 21:09:00'),
    (4, 'Elias M.', 'Frost Hollow Cabin', 'board game', '2025-12-24 20:31:00'),
    (5, 'Ravi P.', '45 Maple Street', 'wooden train set', '2025-12-24 18:23:00'),
    (6, 'Jonah W.', '77 Snowflake Road', 'plush reindeer', '2025-12-24 20:34:00'),
    (7, 'Ava J.', '123 Evergreen Lane', 'board game', '2025-12-24 21:03:00'),
    (8, 'Omar Q.', '77 Snowflake Road', 'board game', '2025-12-24 18:56:00'),
    (9, 'Nia G.', 'Frost Hollow Cabin', 'teddy bear', '2025-12-24 21:27:00'),
    (10, 'Zara S.', 'North Pole Annex', 'wooden train set', '2025-12-24 20:58:00'),
    (11, 'Ravi P.', 'Frost Hollow Cabin', 'puzzle box', '2025-12-24 18:39:00'),
    (12, 'Jonah W.', '123 Evergreen Lane', 'puzzle box', '2025-12-24 18:23:00'),
    (13, 'Ravi P.', 'North Pole Annex', 'storybook collection', '2025-12-24 21:36:00'),
    (14, 'Lena F.', 'North Pole Annex', 'teddy bear', '2025-12-24 21:26:00'),
    (15, 'Ava J.', 'North Pole Annex', 'snow globe', '2025-12-24 18:31:00'),
    (16, 'Elias M.', 'Frost Hollow Cabin', 'robot toy', '2025-12-24 20:21:00'),
    (17, 'Sofia K.', 'Frost Hollow Cabin', 'teddy bear', '2025-12-24 20:27:00'),
    (18, 'Jonah W.', '77 Snowflake Road', 'storybook collection', '2025-12-24 20:49:00'),
    (19, 'Jonah W.', 'Frost Hollow Cabin', 'art supplies', '2025-12-24 21:38:00'),
    (20, 'Jonah W.', '123 Evergreen Lane', 'storybook collection', '2025-12-24 19:11:00');

INSERT INTO misdelivered_presents
(id, child_name, delivery_location, gift_name, scheduled_at, flagged_at, reason)
VALUES
    (601, 'Priya D.', 'The Vibes', 'plush reindeer', '2025-12-24 14:00:00', '2025-12-24 14:05:00', 'Invalid delivery location'),
    (602, 'Lena F.', 'Abandoned Lighthouse', 'board game', '2025-12-22 06:00:00', '2025-12-22 06:05:00', 'Invalid delivery location'),
    (603, 'Caleb O.', 'Drifting Igloo', 'board game', '2025-12-24 06:00:00', '2025-12-24 06:05:00', 'Invalid delivery location'),
    (604, 'Mateo C.', 'The Vibes', 'art supplies', '2025-12-22 04:00:00', '2025-12-22 04:05:00', 'Invalid delivery location'),
    (605, 'Hiro T.', 'The Vibes', 'robot toy', '2025-12-24 08:00:00', '2025-12-24 08:05:00', 'Invalid delivery location'),
    (606, 'Priya D.', 'Volcano Rim', 'puzzle box', '2025-12-22 08:00:00', '2025-12-22 08:05:00', 'Invalid delivery location'),
    (607, 'Nia G.', 'Abandoned Lighthouse', 'board game', '2025-12-24 01:00:00', '2025-12-24 01:05:00', 'Invalid delivery location'),
    (608, 'Elias M.', 'Drifting Igloo', 'board game', '2025-12-24 01:00:00', '2025-12-24 01:05:00', 'Invalid delivery location'),
    (609, 'Ravi P.', 'Volcano Rim', 'board game', '2025-12-24 02:00:00', '2025-12-24 02:05:00', 'Invalid delivery location'),
    (610, 'Hiro T.', 'Abandoned Lighthouse', 'science kit', '2025-12-23 20:00:00', '2025-12-23 20:05:00', 'Invalid delivery location'),
    (611, 'Priya D.', 'Drifting Igloo', 'puzzle box', '2025-12-22 21:00:00', '2025-12-22 21:05:00', 'Invalid delivery location'),
    (612, 'Hiro T.', 'Volcano Rim', 'art supplies', '2025-12-23 09:00:00', '2025-12-23 09:05:00', 'Invalid delivery location'),
    (613, 'Jonah W.', 'Abandoned Lighthouse', 'board game', '2025-12-24 01:00:00', '2025-12-24 01:05:00', 'Invalid delivery location'),
    (614, 'Omar Q.', 'Volcano Rim', 'art supplies', '2025-12-22 01:00:00', '2025-12-22 01:05:00', 'Invalid delivery location'),
    (615, 'Omar Q.', 'Drifting Igloo', 'science kit', '2025-12-23 20:00:00', '2025-12-23 20:05:00', 'Invalid delivery location'),
    (616, 'Omar Q.', 'Abandoned Lighthouse', 'teddy bear', '2025-12-24 12:00:00', '2025-12-24 12:05:00', 'Invalid delivery location'),
    (617, 'Zara S.', 'Volcano Rim', 'wooden train set', '2025-12-24 12:00:00', '2025-12-24 12:05:00', 'Invalid delivery location'),
    (618, 'Omar Q.', 'Abandoned Lighthouse', 'teddy bear', '2025-12-23 15:00:00', '2025-12-23 15:05:00', 'Invalid delivery location'),
    (619, 'Caleb O.', 'The Vibes', 'teddy bear', '2025-12-24 14:00:00', '2025-12-24 14:05:00', 'Invalid delivery location'),
    (620, 'Nia G.', 'Abandoned Lighthouse', 'board game', '2025-12-23 03:00:00', '2025-12-23 03:05:00', 'Invalid delivery location');
SELECT * FROM deliveries;
SELECT * FROM misdelivered_presents;

We have two tables. Almost the same with critical logical distinction among them and one extra column.

[]

Advent of SQL 2025 Day 9: Evergreen Market Orders

Advent of SQL, Day 9 - Evergreen Market Orders

We are on day 9 of advent of SQL, and I feel good so far.

Let’s see what we learn today?

Let’s get the inserts for the day.

sqlite> .read day9-inserts.sql
sqlite> .schema
CREATE TABLE orders (
    id           INT PRIMARY KEY,
    customer_id  INT,
    created_at   TIMESTAMP,
    order_data   JSONB
);
sqlite> .mode table
sqlite> SELECT * FROM orders limit 10;
+----+-------------+---------------------+--------------------------------------------------------------+
| id | customer_id |     created_at      |                          order_data                          |
+----+-------------+---------------------+--------------------------------------------------------------+
| 1  | 1           | 2025-11-21 13:08:22 | {"shipping": {"method": "standard"}, "gift": {"wrapped": tru |
|    |             |                     | e}}                                                          |
+----+-------------+---------------------+--------------------------------------------------------------+
| 2  | 1           | 2025-11-21 18:42:58 | {"shipping": {"method": "overnight"}, "risk": {"flag": "high |
|    |             |                     | "}, "gift": {"wrapped": false}}                              |
+----+-------------+---------------------+--------------------------------------------------------------+
| 3  | 1           | 2025-11-21 21:01:46 | {"shipping": {"method": "standard"}, "gift": {"wrapped": fal |
|    |             |                     | se}}                                                         |
+----+-------------+---------------------+--------------------------------------------------------------+
| 4  | 1           | 2025-11-24 13:17:27 | {"shipping": {"method": "standard"}, "gift": {"wrapped": tru |
|    |             |                     | e}}                                                          |
+----+-------------+---------------------+--------------------------------------------------------------+
| 5  | 1           | 2025-11-24 21:09:46 | {"shipping": {"method": "overnight"}, "gift": {"wrapped": fa |
|    |             |                     | lse}}                                                        |
+----+-------------+---------------------+--------------------------------------------------------------+
| 6  | 1           | 2025-11-25 07:24:55 | {"shipping": {"method": "standard"}, "risk": {"flag": "mediu |
|    |             |                     | m"}, "gift": {"wrapped": true}}                              |
+----+-------------+---------------------+--------------------------------------------------------------+
| 7  | 1           | 2025-11-25 17:42:36 | {"shipping": {"method": "standard"}, "gift": {"wrapped": fal |
|    |             |                     | se}}                                                         |
+----+-------------+---------------------+--------------------------------------------------------------+
| 8  | 1           | 2025-11-27 02:34:24 | {"shipping": {"method": "express"}, "gift": {"wrapped": true |
|    |             |                     | }}                                                           |
+----+-------------+---------------------+--------------------------------------------------------------+
| 9  | 1           | 2025-11-30 22:43:54 | {"shipping": {"method": "overnight"}, "gift": {"wrapped": tr |
|    |             |                     | ue}}                                                         |
+----+-------------+---------------------+--------------------------------------------------------------+
| 10 | 1           | 2025-12-01 04:03:33 | {"shipping": {"method": "express"}, "risk": {"flag": "medium |
|    |             |                     | "}, "gift": {"wrapped": false}}                              |
+----+-------------+---------------------+--------------------------------------------------------------+
sqlite> 

Looks like we will deal with JSON today, seems exciting. I haven’t dealt with JSON in SQLite yet, today will break it.

[]

Advent of SQL 2025 Day 8: Product Catalog

Advent of SQL - Day 8, Product Catalog

Whopsies! This is day 8.

Let’s get straigh…

HOOH! We need to clean up some SQL for running in SQLite.

sed -i 's/TIMESTAMP[[:space:]]*//g' day8-inserts-sqlite.sql

Just cleaning up TIMESTAMP in INSERT before the date value.

Here we go: The SQL to run in SQLite.

DROP TABLE IF EXISTS price_changes;
DROP TABLE IF EXISTS products;

CREATE TABLE products (
    product_id INT PRIMARY KEY,
    product_name TEXT
);

CREATE TABLE price_changes (
    id INT PRIMARY KEY,
    product_id INT,
    price NUMERIC(10,2),
    effective_timestamp 
);

INSERT INTO products (product_id, product_name) VALUES
    (1, 'Deluxe Sled'),
    (2, 'Holiday Trail Mix Trio'),
    (3, 'Premium Cinnamon Roasted Almonds'),
    (4, 'Deluxe Wrapping Paper'),
    (5, 'Deluxe Roasted Cashews'),
    (6, 'Festive Cookware Set'),
    (7, 'Deluxe Mug'),
    (8, 'Premium Sled'),
    (9, 'Essential Sled'),
    (10, 'Family Snow Boots'),
    (11, 'Family Dark Chocolate Almonds'),
    (12, 'Premium Festive Scarf'),
    (13, 'Essential Cookie Decorating Kit'),
    (14, 'Festive White Chocolate Popcorn'),
    (15, 'Cozy Puzzle'),
    (16, 'Holiday Cheddar Popcorn'),
    (17, 'Premium Board Game'),
    (18, 'Deluxe Pecan Praline Bites'),
    (19, 'Cozy Almond Brittle'),
    (20, 'Winter Sled');

INSERT INTO price_changes (id, product_id, price, effective_timestamp) VALUES
    (1, 1, 148.28, '2025-12-01 05:25:35'),
    (2, 1, 148.63, '2025-12-02 18:15:33'),
    (3, 1, 126.78, '2025-12-02 18:40:38'),
    (4, 1, 119.12, '2025-12-03 10:14:35'),
    (5, 1, 98.57, '2025-12-04 04:14:31'),
    (6, 1, 88.49, '2025-12-06 19:02:40'),
    (7, 1, 80.88, '2025-12-07 10:43:54'),
    (8, 1, 78.88, '2025-12-08 06:45:39'),
    (9, 1, 80.24, '2025-12-08 16:11:11'),
    (10, 1, 73.9, '2025-12-10 14:33:43'),
    (11, 1, 88.2, '2025-12-12 02:21:09'),
    (12, 1, 99.03, '2025-12-12 02:58:14'),
    (13, 1, 100.18, '2025-12-14 15:58:03'),
    (14, 1, 106.91, '2025-12-16 01:51:05'),
    (15, 1, 109.25, '2025-12-16 16:01:53'),
    (16, 2, 29.54, '2025-12-03 14:21:10'),
    (17, 2, 34.33, '2025-12-03 19:14:31'),
    (18, 2, 39.08, '2025-12-04 06:13:48'),
    (19, 2, 32.71, '2025-12-04 18:33:17'),
    (20, 2, 31.71, '2025-12-05 22:36:14'),
    (21, 2, 28.88, '2025-12-06 02:42:02'),
    (22, 2, 23.14, '2025-12-07 09:46:54'),
    (23, 2, 25.65, '2025-12-07 10:03:45'),
    (24, 2, 27.06, '2025-12-07 14:39:15'),
    (25, 2, 24.48, '2025-12-07 20:08:05'),
    (26, 2, 26.84, '2025-12-09 07:44:32'),
    (27, 2, 27.39, '2025-12-13 06:25:19'),
    (28, 2, 26.6, '2025-12-14 10:16:34'),
    (29, 2, 21.38, '2025-12-15 16:20:20'),
    (30, 2, 17.75, '2025-12-16 09:28:13');

We can get started.

[]

Advent of SQL 2025 Day 7: Polar Express Mixin

Advent of SQL, Day 7 - Polar Express

There were a few things, I had to dig up for converting the JSON ARRAY[] in the statements into strings for SQLite, we can’t really use list of strings in SQLite.

Here’s the command to convert that array of strings into string.

sed "s/ARRAY\['/'\[\"/g; s/','/\",\"/g; s/']/\"]'/g" day7-inserts.sql > day7-inserts-sqlite.sql

OK, once that’s done, this can be safely run into a sqlite database.

$ sqlite3
SQLite version 3.45.1 2024-01-30 16:01:20
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .read day7-inserts-sqlite.sql
sqlite> .schema
CREATE TABLE passengers (
    passenger_id INT PRIMARY KEY,
    passenger_name TEXT,
    favorite_mixins TEXT[],
    car_id INT
);
CREATE TABLE cocoa_cars (
    car_id INT PRIMARY KEY,
    available_mixins TEXT[],
    total_stock INT
);
sqlite> 
sqlite> .mode table
sqlite> select * from passengers limit 20;
+--------------+----------------+--------------------------------------------------------------+--------+
| passenger_id | passenger_name |                       favorite_mixins                        | car_id |
+--------------+----------------+--------------------------------------------------------------+--------+
| 1            | Ava Johnson    | ["vanilla foam"]                                             | 2      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 2            | Mateo Cruz     | ["caramel drizzle","shaved chocolate","white chocolate"]     | 2      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 3            | Nia Grant      | ["shaved chocolate"]                                         | 5      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 4            | Hiro Tanaka    | ["shaved chocolate"]                                         | 2      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 5            | Layla Brooks   | ["crispy rice","dark chocolate","caramel drizzle","cinnamon" | 3      |
|              |                | ]                                                            |        |
+--------------+----------------+--------------------------------------------------------------+--------+
| 6            | Ravi Patel     | ["caramel drizzle","shaved chocolate","white chocolate"]     | 5      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 7            | Sofia Kim      | ["cinnamon"]                                                 | 9      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 8            | Jonah Wolfe    | ["cinnamon","dark chocolate"]                                | 7      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 9            | Elena Morales  | ["white chocolate","shaved chocolate","caramel drizzle"]     | 6      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 10           | Diego Ramos    | ["shaved chocolate"]                                         | 1      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 11           | Zara Sheikh    | ["vanilla foam","crispy rice","peppermint"]                  | 4      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 12           | Caleb Osei     | ["shaved chocolate","dark chocolate","white chocolate"]      | 8      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 13           | Mila Novak     | ["crispy rice","cinnamon"]                                   | 4      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 14           | Lucas Ford     | ["vanilla foam","white chocolate","cinnamon"]                | 4      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 15           | Yara Haddad    | ["white chocolate","dark chocolate"]                         | 2      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 16           | Omar Qureshi   | ["marshmallow"]                                              | 3      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 17           | Keiko Ito      | ["vanilla foam","marshmallow"]                               | 7      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 18           | Tariq Hassan   | ["dark chocolate","crispy rice","white chocolate","peppermin | 2      |
|              |                | t"]                                                          |        |
+--------------+----------------+--------------------------------------------------------------+--------+
| 19           | Mira Zhao      | ["caramel drizzle","marshmallow","cinnamon"]                 | 7      |
+--------------+----------------+--------------------------------------------------------------+--------+
| 20           | Bianca Pereira | ["dark chocolate","peppermint"]                              | 5      |
+--------------+----------------+--------------------------------------------------------------+--------+
sqlite> 
sqlite> select * from cocoa_cars;
+--------+--------------------------------------------------------------+-------------+
| car_id |                       available_mixins                       | total_stock |
+--------+--------------------------------------------------------------+-------------+
| 5      | ["white chocolate","shaved chocolate"]                       | 412         |
+--------+--------------------------------------------------------------+-------------+
| 2      | ["cinnamon","marshmallow","caramel drizzle"]                 | 359         |
+--------+--------------------------------------------------------------+-------------+
| 9      | ["crispy rice","peppermint","caramel drizzle","shaved chocol | 354         |
|        | ate"]                                                        |             |
+--------+--------------------------------------------------------------+-------------+
| 4      | ["shaved chocolate","white chocolate"]                       | 338         |
+--------+--------------------------------------------------------------+-------------+
| 8      | ["vanilla foam","marshmallow"]                               | 263         |
+--------+--------------------------------------------------------------+-------------+
| 1      | ["peppermint","crispy rice"]                                 | 205         |
+--------+--------------------------------------------------------------+-------------+
| 6      | ["shaved chocolate","dark chocolate","crispy rice","cinnamon | 161         |
|        | ","peppermint"]                                              |             |
+--------+--------------------------------------------------------------+-------------+
| 7      | ["caramel drizzle","crispy rice","marshmallow","vanilla foam | 132         |
|        | ","cinnamon"]                                                |             |
+--------+--------------------------------------------------------------+-------------+
| 3      | ["vanilla foam","peppermint"]                                | 95          |
+--------+--------------------------------------------------------------+-------------+
sqlite> 

Here’s your full SQL file:

[]

Advent of SQL 2025 Day 6: Days of Delight

Advent of SQL Day 6: Days of Delight

It is day 6 of advent of SQL.

Let’s jump straight into the sql for the day.

DROP TABLE IF EXISTS families;
DROP TABLE IF EXISTS deliveries_assigned;

CREATE TABLE families (
    id INT PRIMARY KEY,
    family_name TEXT
);

CREATE TABLE deliveries_assigned (
    id INT PRIMARY KEY,
    family_id INT,
    gift_date DATE,
    gift_name TEXT
);

INSERT INTO families (id, family_name) VALUES
    (1, 'Isla Martinez'),
    (2, 'Nolan Garcia'),
    (3, 'Yara Chen'),
    (4, 'Tariq Nguyen'),
    (5, 'Mila Hernandez'),
    (6, 'Casey Kim'),
    (7, 'Mateo Hernandez'),
    (8, 'Keiko Petrov'),
    (9, 'Ethan Flores'),
    (10, 'Mateo Nakamura'),
    (11, 'Maya Fernandez'),
    (12, 'Mila Davis'),
    (13, 'Yara Rossi'),
    (14, 'Nolan Phillips'),
    (15, 'Amina Perez');

INSERT INTO deliveries_assigned (id, family_id, gift_date, gift_name) VALUES
    (1, 1, '2025-12-01', 'roasted cashews'),
    (2, 1, '2025-12-02', 'cookie decorating kit'),
    (3, 1, '2025-12-03', 'dark chocolate assortment'),
    (4, 1, '2025-12-04', 'white chocolate candies'),
    (5, 1, '2025-12-05', 'reindeer headband'),
    (6, 1, '2025-12-06', 'holiday brownie bites'),
    (7, 1, '2025-12-07', 'shortbread cookie tin'),
    (8, 1, '2025-12-08', 'chocolate chip cookies'),
    (9, 1, '2025-12-11', 'holiday jam trio'),
    (10, 1, '2025-12-12', 'white chocolate popcorn'),
    (11, 1, '2025-12-14', 'holiday jam trio'),
    (12, 1, '2025-12-15', 'fudge bites'),
    (13, 1, '2025-12-16', 'holiday sticker sheet'),
    (14, 1, '2025-12-18', 'hot cocoa bombs'),
    (15, 1, '2025-12-19', 'honey roasted nuts'),
    (16, 1, '2025-12-20', 'holiday mug'),
    (17, 1, '2025-12-21', 'white chocolate candies'),
    (18, 1, '2025-12-22', 'puzzle book'),
    (19, 1, '2025-12-23', 'snowman plush'),
    (20, 1, '2025-12-24', 'scented hand cream'),
    (21, 1, '2025-12-25', 'vanilla bean wafers'),
    (22, 2, '2025-12-01', 'roasted cashews'),
    (23, 2, '2025-12-02', 'holiday brownie bites'),
    (24, 2, '2025-12-03', 'peppermint bark bites'),
    (25, 2, '2025-12-04', 'holiday jam trio'),
    (26, 2, '2025-12-05', 'festive notepad'),
    (27, 2, '2025-12-06', 'scented pine sachet'),
    (28, 2, '2025-12-07', 'holiday mug'),
    (29, 2, '2025-12-08', 'shortbread cookie tin'),
    (30, 2, '2025-12-09', 'dark chocolate assortment');

So, we have two tables:

[]

Advent of SQL 2025 Day 5: EchoTrack Wrapped

Advent of SQL Day 5 - EchoTrack Wrapped

It is day 5 of advent of SQL.

Let’s get rollin. It looks like a good problem. I am excited!

Here’s the SQL to get started.

DROP TABLE IF EXISTS listening_logs;

CREATE TABLE listening_logs (
    id INTEGER PRIMARY KEY,
    user_name TEXT,
    artist TEXT,
    played_at TIMESTAMP,
    content_type TEXT
);

INSERT INTO listening_logs (id, user_name, artist, played_at, content_type) VALUES
    (1, 'Zoe Garcia', 'Arijit Singh', '2025-04-08 00:21:53', 'song'),
    (2, 'Zoe Garcia', 'Huberman Lab', '2025-11-10 19:18:47', 'podcast'),
    (3, 'Zoe Garcia', 'Huberman Lab', '2025-01-20 15:31:02', 'podcast'),
    (4, 'Zoe Garcia', 'Arijit Singh', '2025-01-06 17:33:11', 'song'),
    (5, 'Zoe Garcia', 'Candace', '2025-03-06 14:07:54', 'podcast'),
    (6, 'Zoe Garcia', 'Arijit Singh', '2025-06-05 17:57:59', 'song'),
    (7, 'Zoe Garcia', 'Huberman Lab', '2025-01-01 20:05:22', 'podcast'),
    (8, 'Zoe Garcia', 'Huberman Lab', '2025-11-01 12:04:03', 'podcast'),
    (9, 'Zoe Garcia', 'Arijit Singh', '2025-09-28 12:42:12', 'song'),
    (10, 'Zoe Garcia', 'The Ben Shapiro Show', '2025-09-15 01:05:15', 'podcast'),
    (11, 'Zoe Garcia', 'Arijit Singh', '2025-04-26 05:31:02', 'song'),
    (12, 'Zoe Garcia', 'Arijit Singh', '2025-10-13 17:34:03', 'song'),
    (13, 'Zoe Garcia', 'Mariah Carey', '2025-01-20 11:21:37', 'song'),
    (14, 'Zoe Garcia', 'Arijit Singh', '2025-11-28 03:55:31', 'song'),
    (15, 'Zoe Garcia', 'Arijit Singh', '2025-07-17 05:18:16', 'song'),
    (16, 'Zoe Garcia', 'Arijit Singh', '2025-08-20 02:07:45', 'song'),
    (17, 'Zoe Garcia', 'Kendrick Lamar', '2025-02-16 13:25:27', 'song'),
    (18, 'Zoe Garcia', 'Huberman Lab', '2025-08-13 19:55:00', 'podcast'),
    (19, 'Zoe Garcia', 'Bruno Mars', '2025-09-13 07:09:43', 'song'),
    (20, 'Zoe Garcia', 'Arijit Singh', '2025-04-12 06:30:44', 'song');

Let’s open a SQLite shell and get started.

[]

Techstructive Weekly #73

Week 73

A pretty slow and sluggish week, but some momentum carried in the end. There was a disappointment after a glimmer of excitement when gemini 3 Flash dropped for the experiments that I was running for extraction of documents. It was maybe just the timing, but after this seeing code execution from chats, it was amazing. A good end to the work week.