Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Active Customer List by City

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

Your question is Active Customer List by City. 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

You are given a customer table from an Eli Lilly commercial analytics environment and asked to write a SQL query that returns the number of active customers in each city. Your result should include the city and the count of active customers, sorted by the customer count in descending order and then by city name ascending. Use only the customers table.

Schema

customers
ColumnTypeDescription
customer_idPKINTUnique customer identifier
customer_nameVARCHAR(100)Customer full name
cityVARCHAR(100)Customer city
statusVARCHAR(20)Customer account status
signup_dateDATEDate the customer signed up
Tablescustomers
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results