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 temp2.I, temp2.A, temp2.WNN, temp2.P FROM
(SELECT MIN(W1.COINS_NEEDED) AS WN, WP1.AGE as AG, W1.POWER AS PW
FROM WANDS W1
INNER JOIN WANDS_PROPERTY WP1 ON W1.CODE=WP1.CODE
GROUP BY W1.POWER, WP1.AGE
ORDER BY W1.POWER DESC, WP1.AGE DESC) temp1
INNER JOIN
(SELECT W.ID AS I, W.COINS_NEEDED AS WNN, WP.AGE as A, W.POWER AS P
FROM WANDS W INNER JOIN WANDS_PROPERTY WP ON W.CODE=WP.CODE
WHERE WP.IS_EVIL=0
) temp2
ON temp1.WN=temp2.WNN AND temp1.PW=temp2.P AND temp1.AG=temp2.A
ORDER BY temp2.P DESC, temp2.A DESC, temp2.I;
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 →
SELECT temp2.I, temp2.A, temp2.WNN, temp2.P FROM (SELECT MIN(W1.COINS_NEEDED) AS WN, WP1.AGE as AG, W1.POWER AS PW FROM WANDS W1 INNER JOIN WANDS_PROPERTY WP1 ON W1.CODE=WP1.CODE GROUP BY W1.POWER, WP1.AGE ORDER BY W1.POWER DESC, WP1.AGE DESC) temp1 INNER JOIN (SELECT W.ID AS I, W.COINS_NEEDED AS WNN, WP.AGE as A, W.POWER AS P
FROM WANDS W INNER JOIN WANDS_PROPERTY WP ON W.CODE=WP.CODE WHERE WP.IS_EVIL=0 ) temp2 ON temp1.WN=temp2.WNN AND temp1.PW=temp2.P AND temp1.AG=temp2.A ORDER BY temp2.P DESC, temp2.A DESC, temp2.I;