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.