Sign in to run and submit your work
Reading is open to everyone. Running code and saving drafts need an account so your work is yours and comes back on your next visit.
or
CODE WORKSPACE
Return event_id, device, and campaign; missing campaign should be unknown.
Result columns · in this order
event_iddevicecampaignHow to approach it
Extract payload fields with explicit aliases.
Sample input
| event_id | payload |
|---|---|
| 1 | {"device":"ios","campaign":"winter"} |
| 3 | {"device":"web","campaign":"spring"} |
| 4 | {"device":"web","items":["SKU-C"]} |
| 6 | {"device":"ios"} |
4 rows — all rows shown.
Expected output
| event_id | device | campaign |
|---|---|---|
| 1 | ios | winter |
| 2 | ios | winter |
| 3 | web | spring |
| 4 | web | unknown |
| 5 | android | winter |
| 6 | ios | unknown |
6 rows — all rows shown.
Constraints
Use json_extract and COALESCE. Order by event_id.
Expected skills
JSON path extraction and missing-key defaults.
Submit for review to find out what your query gets right, what it gets wrong, and how it compares with the best working query for this exercise.
This scenario runs a full workspace — editor, canvas and results side by side. It needs a laptop or desktop to be usable. Open this page on a bigger screen to start building.