Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL for Inactive Customers

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

Your question is SQL for Inactive Customers. Start with the requirements and the two 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

Albertsons for U needs a customer re-engagement list for accounts that have not placed an order recently. Using the data below and 2026-08-29 as the reporting date, write a PostgreSQL query to identify customers with no order in the last 90 days.

Requirements

  1. Return every customer who has no order from 2026-05-31 through 2026-08-29, inclusive.
  2. Include the customer's ID, name, and most recent order date across all available order history.
  3. Include customers who have never placed an order, and sort the results by customer_id ascending.

Schema

customers
ColumnTypeDescription
customer_idPKINTEGERUnique customer identifier
customer_nameVARCHAR(100)Customer's full name
emailVARCHAR(255)Customer email address
orders
ColumnTypeDescription
order_idPKINTEGERUnique order identifier
customer_idINTEGERAssociated customer identifier
order_dateDATEDate the order was placed
Tablescustomersorders
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results