Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Second-Highest Marketplace Transactions User

Medium
MediumSQL & Data ManipulationSubqueriesRankingAggregationsAsked 1 times

Problem

Meta Marketplace wants to identify the user with the second-highest number of completed transactions. Write a SQL query to return that user.

Requirements

  1. Count only transactions where status = 'completed'.
  2. Return the user or users tied for the second-highest completed transaction count.
  3. Include user_id, user_name, and completed_transaction_count in the output.
  4. Order the final result by user_id ascending.

Schema

users
ColumnTypeDescription
user_idPKINTPrimary key for the user
user_nameVARCHAR(100)Meta Marketplace user name
regionVARCHAR(50)User region
signup_dateDATEDate the user signed up
transactions
ColumnTypeDescription
transaction_idPKINTPrimary key for the transaction
user_idINTUser who initiated the transaction
amountDECIMAL(10,2)Transaction amount
statusVARCHAR(20)Transaction status
transaction_dateDATEDate of the transaction
Practicing as: Solutions Architect interview at Meta

Hi, I'll play your Meta interviewer for the Solutions Architect role. Answer the question above like we're in the room, and I'll respond the way a real interviewer would.

Take this as a live interview session →

You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.

Sign up freeI have an account
SELECT ...
FROM ...
JOIN ... ON ...
GROUP BY ...
HAVING ...
ORDER BY ... DESC;
Sign up to unlock solutions
Meta Solutions Architect Interview QuestionsTop 50 Subqueries Interview QuestionsTop 50 Ranking Interview Questions
Next questions
MetaSecond Purchase Within 24 HoursEasyMetaSecond Most Recent Marketplace PurchaseHardOneSecond-Highest Transaction SQLMedium