Exercise

Create a temp table

Find the Fortune 500 companies that have profits in the top 20% for their sector (compared to other Fortune 500 companies).

To do this, first, find the 80th percentile of profit for each sector with

percentile_disc(fraction) 
WITHIN GROUP (ORDER BY sort_expression)

and save the results in a temporary table.

Then join fortune500 to the temporary table to select companies with profits greater than the 80th percentile cut-off.

Instructions 1/2

undefined XP
    1
    2
  • Create a temporary table called profit80 containing the sector and 80th percentile of profits for each sector.
  • Alias the percentile column as pct80.