Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Second-Highest Client Transaction Amount

Medium
MediumSQL & Data ManipulationWindow FunctionsSubqueriesRanking
Asked 1mo ago|
Mufg - Mitsubishi Ufj Financial Group
Mufg - Mitsubishi Ufj Financial Group
Asked 18 times

Problem

Write a PostgreSQL query to return the second-highest distinct transaction amount for each client. Include client_id, client_name, and second_highest_amount. Exclude clients that do not have at least two distinct non-NULL transaction amounts.

Schema

ColumnTypeDescription
client_id
client_name
segment
ColumnTypeDescription
transaction_id
client_id
amount
transaction_date

Representative Rows

clients
1Ava PatelInstitutional
4Daniel KimInstitutional
6Farah AliRetail
transactions
1011900.002024-03-12
1021500.002024-02-10
10941100.002024-03-15
1146450.002024-02-21
Practicing as: Data Scientist interview at The Ameriprise

Hi, I'll play your The Ameriprise interviewer for the Data Scientist role. Candidates describe these interviews as mostly positive and moderately difficult, so expect me to be friendly and conversational. Take your time with the question above and answer like we're in the room.

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
Petco Software Engineer Interview QuestionsTata Consultancy Services (North America) Business Analyst Interview QuestionsT. Rowe Price Data Analyst Interview QuestionsWells Fargo Business Analyst Interview QuestionsJellyfish Data Analyst Interview Questions
Next questions
InfosysSecond-Highest Transaction Amount QueryMediumMcKinsey &Second-Highest Segment Transaction ValueMediumFreechargeSecond-Highest Transaction AmountMedium