We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
with cte as
(
select w.ID ,wp.age,w.coins_needed,w.power,ROW_NUMBER() over (partition by w.power,wp.age order by w.power desc,wp.age desc) as t from wands w
join
wands_property wp
on w.code=wp.code
where wp.is_evil != 1
)
select ID,age,coins_needed,power from cte where t=1
order by power desc,age desc,coins_needed asc
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ollivander's Inventory
You are viewing a single comment's thread. Return to all comments →
with cte as ( select w.ID ,wp.age,w.coins_needed,w.power,ROW_NUMBER() over (partition by w.power,wp.age order by w.power desc,wp.age desc) as t from wands w join wands_property wp on w.code=wp.code where wp.is_evil != 1 ) select ID,age,coins_needed,power from cte where t=1 order by power desc,age desc,coins_needed asc