Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Taskers by Category

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Top Taskers by Category. Start with the requirements and the three tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Identify the top 3 Taskers by revenue in each category for the last month on TaskRabbit.

Use completed bookings only, with revenue based on the booking amount. Treat the last month as the previous calendar month relative to the query execution date.

Output

  1. One row per qualifying Tasker and category, with category_name, tasker_id, tasker_name, total_revenue, and revenue_rank.
  2. Include at most three Taskers per category, ordered by category name, revenue descending, and Tasker ID ascending for ties.

Schema

taskers
ColumnTypeDescription
tasker_idPKINTUnique Tasker identifier
tasker_nameVARCHAR(100)Tasker display name
service_areaVARCHAR(100)Primary service area
categories
ColumnTypeDescription
category_idPKINTUnique task category identifier
category_nameVARCHAR(100)Task category name
bookings
ColumnTypeDescription
booking_idPKINTUnique booking identifier
tasker_idINTTasker assigned to the booking
category_idINTCategory associated with the booking
amountDECIMAL(10,2)Booking revenue amount
statusVARCHAR(20)Booking status
completed_atTIMESTAMPTimestamp when the booking was completed
Tablestaskerscategoriesbookings
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results