일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 미분적분학
- CNN10
- 정치학
- 데이터분석전문가
- MySQL
- 위대한 수업
- Great Minds
- 조지프 나이
- 당신이 몰랐던 진화론
- Hacker Rank
- 알고리즘
- 맛집
- python
- 자료구조
- 데이터분석전문가가이드
- Baekjoon
- Joseph Samuel Nye Jr.
- ADsP
- 빅데이터
- Udemy
- 후기
- 공부정리
- Progate
- EBS
- 백준
- KMOOC
- K-MOOC
- 누가 진정한 리더인가
- ADP
- 코테
Archives
- Today
- Total
ㅇ
[Hacker Rank_MySQL]문제 풀이#Ollivander's Inventory 본문
SQL > Basic Join > Ollivander's Inventory
Ollivander's Inventory | HackerRank
Help pick out Ron's new wand.
www.hackerrank.com
Hermione decides the best way to choose is by determining the minimum number of gold galleons needed to buy each non-evil wand of high power and age. Write a query to print the id, age, coins_needed, and power of the wands that Ron's interested in, sorted in order of descending power. If more than one wand has same power, sort the result in order of descending age.
The mapping between code and age is one-one, meaning that if there are two pairs, (code1, age1) and (code2, age2), then code1 ≠ code2, age1≠age2.
빨간 글씨는 내가 문제를 풀 때 중요하다고 생각한 부분이다.
SELECT W.ID, WP.AGE, X.CN, W.POWER
FROM (SELECT CODE, MIN(COINS_NEEDED) CN, POWER
FROM WANDS
GROUP BY CODE, POWER) X
JOIN
WANDS W
ON (X.CODE = W.CODE)
AND (X.POWER = W.POWER)
AND (X.CN = W.COINS_NEEDED)
JOIN
WANDS_PROPERTY WP
ON W.CODE = WP.CODE
WHERE WP.IS_EVIL = 0
ORDER BY W.POWER DESC, WP.AGE DESC
반응형
'IT > 코테문제' 카테고리의 다른 글
[Hacker Rank_MySQL]문제 풀이#Challenges (0) | 2022.03.01 |
---|---|
[Hacker Rank_MySQL]문제 풀이#Top Earners (0) | 2022.02.28 |
[Hacker Rank_MySQL]문제 풀이#Top Competitors (0) | 2022.02.27 |
[Hacker Rank_MySQL]문제 풀이#The Report (0) | 2022.02.23 |
[Hacker Rank_MySQL]문제 풀이#Higher Than 75 Marks (0) | 2022.02.21 |
Comments