# Return username and SUM(total_amount) AS total_spent for users whose account_status is 'active' usin

Canonical URL: <https://datadriven.io/problems/return-username-and-sumtotalamount-as-totalspent-for-use-6035989d>

Domain: SQL · Difficulty: medium

## Problem

Return username and SUM(total_amount) AS total_spent for users whose account_status is 'active' using INNER JOIN and GROUP BY. Only return users with total_spent over 50. Order by total_spent descending, then username.

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/return-username-and-sumtotalamount-as-totalspent-for-use-6035989d)
- [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.