Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Simple OVER()
PARTITION BY
13. PARTITION BY – Exercise 3
Ranking functions
Window Frames
Analytic Functions
PARTITION BY ORDER BY
Order of Evaluation
Finished!

Instruction

Good job! Let's do some math with our query.

Exercise

In the GiftCard table, show the:

  1. distinct AmountWorth values for all gift cards,
  2. number of gift cards purchased of that amount (column CountValueGiftCards),
  3. total number of gift cards purchased (column CountGiftCards),
  4. ratio of the number of gift cards of that specific AmountWorth towards the number of all gift cards (as Ratio), expressed as a percentage. Round this column to an integer.

Stuck? Here's a hint!

The last column is the trickiest one. Use ROUND(value, precision). Inside, apply division. To avoid integer division, use CAST(Column AS NUMERIC).