Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
PostgreSQL Active Customer Usage Report
00:00
5 left

PostgreSQL Active Customer Usage Report

MediumSQL · PostgreSQL

Problem

What are the most important SQL joins you use for complex reporting?

Write a PostgreSQL query that demonstrates this reporting task using the provided tables. Include active customers, their active subscription details when available, and usage events during the first quarter of 2026.

Output

  1. One row per active customer, with customer_id, customer_name, plan_name, event_count, and engagement_status.
  2. Use No active subscription when no active subscription exists and Unspecified when an active subscription has no plan name.
  3. Sort by event_count descending, then customer_id ascending.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer display name
customer_statusVARCHAR(30)Current customer status
subscriptions
ColumnTypeDescription
subscription_idPKINTUnique subscription identifier
customer_idINTCustomer owning the subscription
plan_nameVARCHAR(100)Subscription plan name
subscription_statusVARCHAR(40)Current subscription status
usage_events
ColumnTypeDescription
event_idPKINTUnique usage event identifier
customer_idINTCustomer associated with the event
event_dateDATEDate the usage event occurred
event_typeVARCHAR(50)Type of product usage event
Tablescustomerssubscriptionsusage_events
Interviewer

Your question is PostgreSQL Active Customer Usage Report. 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.