Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL for Actionable Insights
00:00
5 left

SQL for Actionable Insights

HardSQL · PostgreSQL

Problem

Explain how you would use SQL to extract actionable insights from a messy, multi-source dataset.

Use the provided customer, sales order, and support ticket tables. Consider inconsistent status values, missing amounts, unmatched source records, inactive customers, and customers with no activity.

Output

  1. One row per active customer.
  2. Include customer_id, customer_name, region, total_revenue, completed_order_count, active_ticket_count, high_priority_active_tickets, last_order_date, and action_status.
  3. Include only orders from 2025-01-01 through 2025-03-31, include customers without matching orders or tickets, and sort by total_revenue descending, then customer_id ascending.

Schema

crm_customers
ColumnTypeDescription
customer_idPKINTCanonical customer identifier
customer_nameVARCHAR(100)Customer display name
regionVARCHAR(50)Customer sales region
emailVARCHAR(255)Customer email address
activeBOOLEANWhether the customer is currently active
sales_orders
ColumnTypeDescription
order_idPKINTSales order identifier
customer_idINTCustomer identifier from the sales source
order_dateDATEDate the order was recorded
amountNUMERIC(12,2)Order amount
order_statusVARCHAR(30)Raw order status from the sales source
support_tickets
ColumnTypeDescription
ticket_idPKINTSupport ticket identifier
customer_idINTCustomer identifier from the support source
opened_atDATEDate the ticket was opened
priorityVARCHAR(20)Raw support priority
statusVARCHAR(20)Raw support ticket status
Tablescrm_customerssales_orderssupport_tickets
Interviewer

Your question is SQL for Actionable Insights. Start with the requirements and the three tables 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.