본문 바로가기
프로젝트(진행중)/MySQL

HackerRank 공부 4

by 일말고프로젝트 2023. 3. 9.

https://www.hackerrank.com/challenges/full-score/problem

 

Top Competitors | HackerRank

Query a list of top-scoring hackers.

www.hackerrank.com

 

문제 핵심


Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in descending order by the total number of challenges in which the hacker earned a full score. If more than one hacker received full scores in same number of challenges, then sort them by ascending hacker_id.

 

다른 사람 풀이

select h.hacker_id, h.name
from hackers h
join submissions s on s.hacker_id = h.hacker_id
join challenges c on c.challenge_id = s.challenge_id
join difficulty d on (
    d.difficulty_level = c.difficulty_level and
    d.score = s.score
)
group by h.hacker_id, h.name
having count(*) > 1
order by count(*) desc, h.hacker_id asc

 

 


https://www.hackerrank.com/challenges/placements/problem

 

Placements | HackerRank

Write a query to output the names of those students whose best friends got offered a higher salary than them.

www.hackerrank.com

 

내 풀이


select t4.Name
from Friends t1
inner join Packages t2
on t1.ID = t2.ID
inner join Packages t3
on t1.Friend_ID = t3.ID
inner join Students t4
on t1.ID = t4.ID
WHERE t2.Salary < t3.Salary
order by t3.Salary
;

 

'프로젝트(진행중) > MySQL' 카테고리의 다른 글

Recursive Table  (0) 2023.03.10
HackerRank 공부 3  (0) 2023.03.06
HackerRank 공부 1  (0) 2023.03.06
프로그래머스 SQL 공부 6  (0) 2023.03.03
프로그래머스 SQL 공부 5  (0) 2023.03.03

댓글