001Level 1

Chapter 7 · CTEs

05. Customer Lifetime Value Tiers

Hard40 XPE-Commerce

Classify customers into lifetime value tiers. First compute each customer's total spend. Then assign: 'Platinum' if spend >= 1000, 'Gold' if >= 500, 'Silver' if >= 100, else 'Bronze'. Return first_name, last_name, total_spend, and tier. Sort by total_spend descending.

Tables

  • PKidINT
  • first_nameTEXT
  • last_nameTEXT
  • emailTEXT
  • phoneTEXT
  • cityTEXT
  • stateTEXT
  • countryTEXT
  • created_atTIMESTAMP
  • PKidINT
  • FKcustomer_id→ customers.idINT
  • order_dateTEXT
  • statusTEXT
  • total_amountREAL

Need help?

Ask Sol

AI tutor — looks at your current query and nudges you, without spoiling the answer.

Solution

Try the hints first — solving it yourself is what makes it stick.

Peek at the solution?

You can still earn the XP afterwards by submitting a working query — but you'll learn more if you give it one more try.