Back-To-School Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Method One
Method Two
Method Three
9. Method 3 – exercise
Summary

Instruction

Good job! Let's do one more exercise of this kind.

Exercise

For each employee, show the percentage of total revenue (before discount) generated by orders shipped to the USA and to Germany. Show the following columns:

  1. employee_id.
  2. first_name.
  3. last_name.
  4. rev_percentage_usa.
  5. rev_percentage_germany.

Round the percentages to two decimal places.

Stuck? Here's a hint!

Write two CTEs, usa_revenue and germany_revenue. You can find the total revenue (before discount) generated by orders shipped to the USA with the following code:

SUM(CASE
  WHEN ship_country = 'USA'
    THEN unit_price * quantity
  ELSE 0
END)