SQL QuestSQL Interview Questions › Subqueries & CTEs

Top 10% Users by Transaction Volume

HardProQuerying BasicsSubqueries & CTEsWindow FunctionsJoinsAggregation & Grouping

The second question candidates report from the live round: who are the top 10% by volume? Volume is the total amount_gbp of a user's completed transactions of any type. Rank users into ten equal buckets with NTILE(10) ordered by volume descending; the first bucket is the top decile.

Return user_id, country, plan (both from users) and volume_gbp (rounded to 2 decimals) for users in the top decile. Order by volume_gbp descending.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

transactions

txn_iduser_idtstypeamountcurrencyamount_gbpfee_gbpmerchant_categorymerchant_countrycounterparty_user_idstatusdecline_reason
112025-06-14 11:01:51fx_exchange32271.15JPY167.811.68NULLNULLNULLcompletedNULL
212025-06-14 11:17:45bill_payment59.53EUR50.60utilitiesIENULLcompletedNULL
372025-06-16 10:06:38card_payment122.27EUR103.930shoppingESNULLcompletedNULL

users

user_idsignup_datecountryhome_currencyplanplan_sincekyc_verified_atreferred_bybirth_year
12025-06-01IEEURstandard2025-06-012025-06-03 16:00:00NULL1972
22025-06-02FREURstandard2025-06-022025-06-04 16:00:00NULL1979
32025-06-03GBGBPstandard2025-06-032025-06-08 04:00:00NULL1977

Expected output: user_id=33, country=PL, plan=standard, volume_gbp=10711.66 ...

Hint

This is a Pro challenge — the hint, the step-by-step tutor and the reference solution open in the app.

Concepts

SELECT CTE Window Functions NTILE JOIN SUM

Practise the topic: SQL practice questions · CTE practice · Window function practice · JOIN practice · GROUP BY exercises · Ranking function practice · Advanced SQL interview questions

In these company practice sets

Revolut

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Cumulative Distinct Customers Over TimeHard · FreeRunning Total RevenueHard · FreeYear-over-Year GrowthHard · Free7-Day Rolling Revenue AverageHard · FreeMulti-CTE Revenue PipelineHard · FreeWealthy Survivor ProfileHard · Pro

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test