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.
Why below code is throwing an error??
SELECT
id,
age,
coins_needed,
power
FROM
(
SELECT
ROW_NUMBER() OVER(PARTITION BY w.power, wp.age ORDER BY w.coins_needed) AS rn,
w.id AS id,
wp.age AS age,
w.coins_needed AS coins_needed,
w.power AS power
FROM Wands w
JOIN Wands_Property wp ON w.code = wp.code
WHERE wp.is_evil=0)t
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 →
Why below code is throwing an error?? SELECT id, age, coins_needed, power FROM ( SELECT ROW_NUMBER() OVER(PARTITION BY w.power, wp.age ORDER BY w.coins_needed) AS rn, w.id AS id, wp.age AS age, w.coins_needed AS coins_needed, w.power AS power FROM Wands w JOIN Wands_Property wp ON w.code = wp.code WHERE wp.is_evil=0)t WHERE rn=1 ORDER BY power DESC, age DESC;