# 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-bbea7492>

Domain: SQL · Difficulty: medium

## Problem

Group events by the 'source' field extracted from payload using JSON_EXTRACT_SCALAR. Return the extracted source and the count of events. 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-bbea7492)
- [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.