NTILE(4), group 1: spending, USD, Sep–Nov 2025
Instructions
A client's spending is the sum of -amount over their transactions with amount < 0 on accounts in the currency USD (accounts.currency), with tx_time on or after September 1, 2025 and strictly before December 1, 2025; clients without such transactions do not participate. Split the clients into 4 groups with NTILE(4) by spending descending (for equal spending, by client id ascending): group 1 has the largest spending, group 4 the smallest; if the number of clients is not divisible by 4, the groups with smaller numbers have one more client than the others. Output the clients of group 1: id, name, 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.