DataLane

18. Traffic source from JSON payload

mediumProNot started~12 minSemi-structuredAggregation

Asked in screens shaped like: Snowflake, Databricks, Airbnb

events.payload is raw JSON with source and campaign keys. Break activity down by source without unloading the column into a staging table first — this is the semi-structured question every warehouse screen has now.

Requirements

  • Columns: source, events, customers
  • source is the payload’s source key
  • events counts rows, customers counts distinct customer_id
  • Order by events descending, then source

Expected output

source, events, customers

Row order is graded, so ORDER BY matters here.

SQL editor

Loading SQL engine…

Ctrl/Cmd + Enter submits

Run your query to see the result set.

Pro problem

Medium problems unlock with Pro

Easy pads stay free. Medium and hard SQL and Python problems — editor, tests, hints, and solutions — open after you upgrade to Pro or coaching.

See plansPractice free easy problems
↑↓ navigate openesc close