@@ -21,13 +21,11 @@ The `specs` column of the products table stores specification information for ea
2121
2222---
2323
24-
2524### Problem 1. JSON Basic Extraction — Laptop CPU List
2625
2726Extract product names and CPU specifications from all active products in the Laptop category.
2827Products with NULL CPU specifications are excluded.
2928
30-
3129??? tip "Hint"
3230 - Extract JSON internal values with ` json_extract(specs, '$.cpu') `
3331 - Filter categories by JOIN with ` categories ` table
@@ -50,16 +48,13 @@ Products with NULL CPU specifications are excluded.
5048 | (laptop product name) | Intel Core i7-13700H |
5149 | ... | ... |
5250
53-
5451---
5552
56-
5753### Problem 2. JSON Multiple Field Extraction — Notebook Spec Sheet
5854
5955Create a spec sheet by extracting the screen size, CPU, RAM (GB), storage capacity (GB), and battery (hours) of your laptop product at once.
6056Sort by price descending.
6157
62-
6358??? tip "Hint"
6459 - Call ` json_extract ` multiple times to extract each field into a separate column
6560 - ` $.screen_size ` , ` $.cpu ` , ` $.ram_gb ` , ` $.storage_gb ` , ` $.battery_hours `
@@ -88,16 +83,13 @@ Sort by price descending.
8883 | (laptop name) | 2500000 | 16 inch | Intel Core i9-13900H | 32 | 1024 | 12 |
8984 | ... | ... | ... | ... | ... | ... | ... |
9085
91-
9286---
9387
94-
9588### Problem 3. Identifying products with NULL specs
9689
9790Check the distribution by category of products without specs information (NULL).
9891The goal is to determine which categories are missing specification information.
9992
100-
10193??? tip "Hint"
10294 - ` WHERE p.specs IS NULL ` condition
10395 - Aggregated by ` GROUP BY ` Category name
@@ -120,16 +112,13 @@ The goal is to determine which categories are missing specification information.
120112 | (peripheral category) | 45 |
121113 | ... | ... |
122114
123-
124115---
125116
126-
127117### Problem 4. List JSON keys — utilizing json_each
128118
129119Pick a laptop product and list all the keys included in the specs JSON.
130120` json_each ` uses table-valued functions.
131121
132-
133122??? tip "Hint"
134123 - ` json_each(specs) ` returns each key-value pair in a JSON object as a row
135124 - Return columns: ` key ` , ` value ` , ` type `
@@ -161,16 +150,13 @@ Pick a laptop product and list all the keys included in the specs JSON.
161150 | storage_gb | 512 | integer |
162151 | battery_hours | 10 | integer |
163152
164-
165153---
166154
167-
168155### Problem 5. JSON Condition Filtering — Finding High-Performance Laptops
169156
170157Look for a laptop with at least 32GB of RAM and at least 1024GB of storage.
171158Displays product name, price, RAM, and storage capacity.
172159
173-
174160??? tip "Hint"
175161 - Use JSON value as condition in WHERE clause like ` json_extract(specs, '$.ram_gb') >= 32 `
176162 - Values extracted from JSON are automatically converted to the appropriate type.
@@ -198,16 +184,13 @@ Displays product name, price, RAM, and storage capacity.
198184 | (high-spec laptop) | 3200000 | 32 | 1024 | Intel Core i9-13900H |
199185 | ... | ... | ... | ... | ... |
200186
201-
202187---
203188
204-
205189### Problem 6. JSON-based group aggregation — average price by CPU
206190
207191Find the average price and number of products by CPU specification for laptops and desktops.
208192Shows only CPUs with 3 or more products.
209193
210-
211194??? tip "Hint"
212195 - Use ` json_extract(specs, '$.cpu') ` for ` GROUP BY `
213196 - Exclude minority groups with ` HAVING COUNT(*) >= 3 `
@@ -236,16 +219,13 @@ Shows only CPUs with 3 or more products.
236219 | AMD Ryzen 9 7950X | 4 | 2500000 | 2000000 | 3000000 |
237220 | ... | ... | ... | ... | ... |
238221
239-
240222---
241223
242-
243224### Problem 7. JSON-based statistics — Analysis by monitor panel type
244225
245226In the monitor category, tally the number of products, average price, and average refresh rate by panel type (IPS/VA/OLED).
246227Also check the resolution distribution of each panel type.
247228
248-
249229??? tip "Hint"
250230 - Use ` json_extract(specs, '$.panel') ` , ` json_extract(specs, '$.refresh_rate') `
251231 - Resolution distribution is processed as a separate query or conditional aggregation (` CASE WHEN ` )
@@ -275,16 +255,13 @@ Also check the resolution distribution of each panel type.
275255 | IPS | 25 | 450000 | 120 | 8 | 10 | 7 |
276256 | VA | 12 | 380000 | 100 | 5 | 5 | 2 |
277257
278-
279258---
280259
281-
282260### Problem 8. Modifying JSON value with json_set (within SELECT)
283261
284262Use SQLite's ` json_set ` function to check the result of adding the ` "warranty_years": 3 ` field to the laptop product's specs.
285263Preview the converted JSON from a SELECT, not an actual UPDATE.
286264
287-
288265??? tip "Hint"
289266 - ` json_set(specs, '$.warranty_years', 3) ` adds a new key to an existing JSON
290267 - If the key already exists, the value is overwritten.
@@ -307,16 +284,13 @@ Preview the converted JSON from a SELECT, not an actual UPDATE.
307284 |---|---|---|
308285 | (laptop name) | {"screen_size":"15.6 inch",...} | {"screen_size":"15.6 inch",...,"warranty_years":3} |
309286
310-
311287---
312288
313-
314289### Problem 9. Removing a JSON key with json_remove (within a SELECT)
315290
316291Compare the original with the result of removing the ` tdp_watts ` key from the GPU product's specs.
317292Use the ` json_remove ` function.
318293
319-
320294??? tip "Hint"
321295 - ` json_remove(specs, '$.tdp_watts') ` returns JSON with the specified key removed
322296 - Display ` specs ` and ` json_remove(...) ` results side by side for comparison with the original
@@ -338,16 +312,13 @@ Use the `json_remove` function.
338312 |---|---|---|
339313 | (GPU name) | {"vram":"16GB","clock_mhz":2100,"tdp_watts":300} | {"vram":"16GB","clock_mhz":2100} |
340314
341-
342315---
343316
344-
345317### Problem 10. Comprehensive JSON analysis — Specification comparison report by category
346318
347319Analyze product specs for all categories to find a list of unique keys included in JSON for each category and the occurrence rate of each key.
348320This report allows you to see at a glance what specification information exists in which category.
349321
350-
351322??? tip "Hint"
352323 - Spread all keys into rows with ` json_each(specs) ` , then GROUP BY with category + key combination
353324 - Appearance rate = Number of products with that key / Total number of products in the category
0 commit comments