Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Second-Highest Transaction Amount Query
00:00
5 left

Second-Highest Transaction Amount Query

MediumSQL · PostgreSQL

Problem

You are given a transaction table from an Infosys Finacle-style payments dataset. Write a PostgreSQL query to return the second-highest distinct transaction amount without using the LIMIT clause. If the highest amount appears multiple times, it should still count as one distinct value, so the query must return the next lower distinct amount.

Schema

transactions
ColumnTypeDescription
transaction_idPKINTUnique transaction identifier
account_idINTAccount associated with the transaction
transaction_typeVARCHAR(20)Type of transaction
amountDECIMAL(10,2)Transaction amount
transaction_dateDATEDate of the transaction
Tablestransactions
Interviewer

Your question is Second-Highest Transaction Amount Query. Start with the requirements and the one table 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.