One Row per Item

One Row per Item

L. wants to analyze products individually, but each basket is stored as an array in the event log. From events, return event_id and item, with one row for every element of items; omit events that contain no items. Sort by event_id, then by item.

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables. Your answer must use the same column names as this sample — alias them with AS if needed.

event_iditem
2dry food
3cat bed
3dry food
PostgreSQLv16

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid