User’s Third Transaction — SQL Questioned Asked By Uber

  • Post last modified:December 15, 2022
  • Reading time:2 mins read
Photo by Caspar Camille Rubin on Unsplash


  • In this article we will solve Teams Power Users SQL question which is asked by Microsoft as per DataLemur website.

If you don’t know DatLemur then please do visit , it’s one of the best website to practice SQL questions and improve your SQL skills.


  • We have been given user_transactions input table. our goal is to find out 3rd transaction made by each user.


  • First we will partition uber_transaction table based on user_id, we will add row_number as column to rank each record.
  • Here is output.
  • Now once we have our base table is ready , we can return cases where row_number is 3

Final Solution

select user_id,spend,transaction_date from(
  select user_id,spend,transaction_date, 
  row_number() over(partition by user_id order by transaction_date) as rn
  from transactions
) x where rn = 3


  • Our solution is accepted by the platform.


  • In this article we solved SQL question asked by Uber. we used window operation and used row_number function to rank each record in the partition.

Bonus Tip

Leave a Reply