# Group events by the 'source' field extracted from payload using JSON_EXTRACT_SCALAR

Canonical URL: <https://datadriven.io/problems/group-events-by-the-source-field-extracted-from-payload-us-2e1073d3>

Domain: SQL · Difficulty: medium

## Problem

Group events by the 'source' field extracted from payload using JSON_EXTRACT_SCALAR. Return the extracted source aliased as traffic_source and the count of events aliased as event_count. Order by event_count descending.

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/group-events-by-the-source-field-extracted-from-payload-us-2e1073d3)
- [SQL Interview Questions](https://datadriven.io/sql-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.