Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Second-Highest Subscriber Payment

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

Your question is Second-Highest Subscriber Payment. Start with the requirements and the one table 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

Write a query to find the second-highest subscriber payment from a billing table.

Return the second-highest distinct non-null payment amount. If fewer than two distinct non-null payment amounts exist, the result should be NULL.

Output

  1. One row with the column second_highest_payment
  2. Return the distinct second-highest payment amount, excluding NULL values
  3. Return exactly one scalar result row

Schema

billing
ColumnTypeDescription
billing_idPKINTUnique billing record identifier
subscriber_idVARCHAR(20)Subscriber identifier
payment_amountDECIMAL(10,2)Payment amount recorded for the billing entry
Tablesbilling
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results