001Level 1

Chapter 2 · Filtering

16. Product Profit Margins

Medium20 XPE-Commerce

Calculate the profit margin for each product as (price - cost) / price * 100. Return the product name, price, cost, and margin rounded to 1 decimal place. Sort by margin descending. Only include products with a positive margin.

Tables

  • PKidINT
  • nameTEXT
  • FKcategory_id→ categories.idINT
  • priceREAL
  • costREAL
  • stock_quantityINT
  • created_atTIMESTAMP

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.