Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL: Accounts Receivable Turnover

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

Your question is SQL: Accounts Receivable Turnover. Start with the requirements and the three tables 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

Huron Consulting Group needs a client-level financial reporting query for its consulting engagements. Calculate each client's 2024 accounts receivable turnover, defined as posted net credit sales divided by average beginning and ending accounts receivable.

Requirements

  1. Include every client, including clients without 2024 invoices or complete balance records.
  2. Count only invoices dated in 2024 with status = 'posted' as net credit sales.
  3. Calculate average accounts receivable from the January 1 and December 31 balances. Return NULL when either balance is missing or the average balance is zero.
  4. Round turnover to two decimal places and order clients by turnover descending, with null values last.

Schema

clients
ColumnTypeDescription
client_idPKINTEGERUnique client identifier
client_nameVARCHAR(120)Client organization name
invoices
ColumnTypeDescription
invoice_idPKINTEGERUnique invoice identifier
client_idINTEGERClient associated with the invoice
invoice_dateDATEInvoice issue date
statusVARCHAR(20)Invoice processing status
net_amountNUMERIC(14,2)Net invoice amount
ar_balances
ColumnTypeDescription
balance_idPKINTEGERUnique balance snapshot identifier
client_idINTEGERClient associated with the balance
as_of_dateDATEDate of the balance snapshot
ending_balanceNUMERIC(14,2)Accounts receivable balance at the snapshot date
Tablesclientsinvoicesar_balances
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results