Mode SQL
Write a query that includes players’ names and a column that classifies them into four categories based on height. Keep in mind that the answer we provide is only one of many possible answers, since you could divide players’ heights in many ways.
Solution:
select percentile_cont(0.25) within group (order by height) as percentiel_1,
percentile_cont(0.5) within group (order by height) as percentile_2,
percentile_cont(0.75) within group (order by height) as percentile_3,
percentile_cont(1) within group (order by height) as percentile_4
from benn.college_football_players;--- get 71, 73.75, 83 ---select player_name,
height,
case when height < 71 then '< 75 percentile'
when 71 <= height and height < 73.75 then 'within 75 and 50 percentile'
when 73.75 <= height and height < 83 then 'within 50 and 25 percentile'
else 'greater then 25 percentile'
end as height_group
from benn.college_football_players;