Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Top Users by Recent Transaction Volume
00:00
5 left

Top Users by Recent Transaction Volume

MediumSQL · PostgreSQL

Problem

FinEdge wants a report of the most active users by recent completed transaction volume. Write a SQL query to return the top 3 users based on completed transactions in the 30-day window ending on 2024-06-30.

Requirements

  1. Use only transactions with status = 'completed'.
  2. Restrict the date range to 2024-05-31 through 2024-06-30, inclusive.
  3. Count only transactions whose card_id belongs to the same user in the cards table.
  4. For each qualifying user, return:
    • user_id
    • full_name
    • country_code
    • total_volume as the sum of ABS(amount)
    • transaction_count
  5. Order by total_volume descending, then user_id ascending.
  6. Return only the top 3 rows.

Schema

users
ColumnTypeDescription
user_idPKINTPrimary key for the user
full_nameVARCHAR(100)User full name
country_codeVARCHAR(2)ISO country code
signup_dateDATEDate the user signed up
transactions
ColumnTypeDescription
transaction_idPKINTPrimary key for the transaction
user_idINTUser who made the transaction
card_idINTCard used for the transaction
amountDECIMAL(12,2)Signed transaction amount
transaction_dateDATEDate of the transaction
statusVARCHAR(20)Transaction status
cards
ColumnTypeDescription
card_idPKINTPrimary key for the card
user_idINTOwner of the card
card_typeVARCHAR(20)Type of card
card_statusVARCHAR(30)Current card status
Tablesuserstransactionscards
Interviewer

Your question is Top Users by Recent Transaction Volume. Start with the requirements and the three tables in the Question tab.

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.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.