Spending above income: vip, RUB, 4 mo.: Mar–Jun 2025
Instructions
Consider transactions on accounts in the currency RUB (accounts.currency) with tx_time on or after March 1, 2025 and strictly before July 1, 2025. A client's income is the sum of transactions with amount > 0, and spending is the sum of the absolute values of transactions with amount < 0 (that is, -sum(amount)); all such accounts of the client are taken. Find clients of the segment 'vip' who had both income and spending, and whose spending is strictly greater than their income. Output id, name, income and spend. Row order does not matter.
Hints
Each next one is more detailed and costs more
Query
Result
Click Run to see the query result, or Check to submit your solution.
Dataset schema
Table relationships
- N:1Many-to-one
accounts.→client_id clients.id - N:1Many-to-one
transactions.→account_id accounts.id
Table data
Select a table in the diagram or list to view its rows.