题意
题解1
select rank () over (order by (total_points) desc)as rank, a.*
from (
select distinct (case when (clan ='') then '[no clan specified]' else clan end)as clan,
sum(points) as total_points,
count(distinct name) as total_people
from people
group by clan)a
题解2-wrong
select rank () over (order by (total_points) desc)as rank, a.*
from (
select distinct replace('clan','','no clan specified') as clan,
sum(points) as total_points,
count(distinct name) as total_people
from people
group by clan)a
题解-LZY
select rank() over (order by sum(points) desc) as rank,
CASE WHEN clan IS NULL OR clan='' THEN '[no clan specified]' ELSE clan END,
sum(points) as total_points, count(*) as total_people
from people
group by clan