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 for each (column CountValueGiftCards),
  3. total number of gift cards purchased (column CountGiftCards),
  4. percentage of that gift card value towards the whole (as Ratio). 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).