Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Multiple metrics for a single object
Metrics for two groups
Ratios and percentages
Global vs. specific metrics
13. Global vs. specific metrics – exercise


Excellent! Let's do another exercise.


For each country, find the percentage of revenue generated by orders shipped to it in 2018. Show three columns:

  1. ShipCountry
  2. Revenue – the total revenue generated by all orders shipped to that country in 2018
  3. RevenuePercentage – the percentage of that year's revenue generated by orders shipped to that country in 2018

Round the percentage to two decimal places. Order the results in descending order by the Revenue column.

Stuck? Here's a hint!

In the inner query, calculate the revenue in 2018. Use the result in the outer query.

Use the following formula to calculate the percentage:

ROUND(SUM(quantity * unitprice) / CAST(TotalSales.Sales2018 AS float) * 100, 2) AS RevenuePercentage