← All SQL interview questions

Cities with a loyal, high-spending buyer base

MediumHAVINGWalmartTarget

A regional expansion team looks for cities that already have both breadth and depth of demand.

From purchase_log, return city, the number of distinct buyers as buyer_count, and total spend as total_spend, keeping only cities that have at least 3 distinct customers and more than 20000 in total spend.

Sample data

More HAVING questions

  • This is the only question on this topic for now.

Practising alone only goes so far — our live cohorts pair SQL depth with dashboards, agentic analytics projects and mock interviews.

Explore the program