Transaction Percentile Tracker:Measure Each Transaction’s Relative Standing Among All Records Using Percentage-Based Ranking
Intermediate
Evaluate transactions by how they rank percent-wise among all others.
The accounting team wants to analyze transactions by their rank as a percentage of all transactions. Write a query to calculate the percent rank of each transaction amount.
Write Your Query
Answer:
select t.transactionid,
o.totalamount,
percent_rank() over (
order by o.totalamount desc) as percentrank
from orders o
join transaction t on o.orderid = t.orderid;
Explanation:
This simulates ranking financial transactions to understand how each compares within the full set of transaction values.
You'll practice ranking data across an entire dataset and expressing each value as a percentage of the whole.
This problem is labeled as Intermediate. It assumes you’ve written a few window function queries before, but you don’t need to be an expert. Use the hints and explanations if you get stuck — they’re there to help you think through the logic.
Yes. Every problem comes with optional hints you can reveal one at a time, plus a fully worked step-by-step solution. You decide how much help you want while practicing.
All problems on PracticeWindowFunctions.com are completely free and can be solved without creating an account. Right now there are over 80 practice problems, with new ones added regularly.