Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Custom classifications of business objects
Custom grouping of business objects
Custom counting of business objects
13. CASE WHEN with SUM – exercise
Summary

Instruction

Good job! Let's write one more query with SUM(), this time from scratch!

Exercise

There have been a lot of orders shipped to France. Of these, how many order items were sold at full price and how many were discounted? Show two columns with the respective counts: full_price and discounted_price.

Stuck? Here's a hint!

Use the discount column from the order_items table.

Here's an example of using SUM() (from the previous exercise):

SELECT 
  SUM(CASE
    WHEN region = 'WA' THEN 1
  END) AS orders_wa_employees,
  SUM(CASE
    WHEN region != 'WA' THEN 1
  END) AS orders_not_wa_employees
FROM employees e
JOIN orders o
  ON e.employee_id = o.employee_id;