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.
select id,age,coins,power from
(select w.id,wp.age,w.coins_needed,w.power,
row_number() over(partition by wp.age,w.power order by w.coins_needed)
from wands w join wands_property wp
on w.code = wp.code and wp.is_evil = 0) nw(id,age,coins,power,rn)
where rn = 1
order by power desc,age desc
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 →
/* ms sql */
select id,age,coins,power from (select w.id,wp.age,w.coins_needed,w.power, row_number() over(partition by wp.age,w.power order by w.coins_needed) from wands w join wands_property wp on w.code = wp.code and wp.is_evil = 0) nw(id,age,coins,power,rn) where rn = 1 order by power desc,age desc