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.
Since we can't use CTE's in this version. Posting the alternate way.
select w.id,wp.age,w.coins_needed,w.power from wands w
join wands_property wp on w.code = wp.code
where is_evil = 0 and
w.coins_needed = (select min(w2.coins_needed) from wands w2
join wands_property wp2 on w2.code = wp2.code
where wp2.code = wp.code and w.power = w2.power and is_evil = 0)
order by w.power desc,wp.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 →
Since we can't use CTE's in this version. Posting the alternate way.
select w.id,wp.age,w.coins_needed,w.power from wands w join wands_property wp on w.code = wp.code where is_evil = 0 and w.coins_needed = (select min(w2.coins_needed) from wands w2 join wands_property wp2 on w2.code = wp2.code where wp2.code = wp.code and w.power = w2.power and is_evil = 0) order by w.power desc,wp.age desc