문제 :
Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! 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.
https://www.hackerrank.com/challenges/full-score/problem?isFullScreen=true
Top Competitors | HackerRank
Query a list of top-scoring hackers.
www.hackerrank.com
2개 이상의 문제에서 만점을 받은 해커들의 아이디와 이름을 출력하고,
만점 문제 개수대로 내림차순, 해커들의 아이디로 오름차순을 하는 문제이다.
문제 해결 :
다른 테이블에서 필요한 정보들을 Submissions 테이블에 left join 하여 활용하는 방식을 사용할 것이다.
실패
필요한 컬럼들만 조인하려고 하다보니 너무 복잡해 보였다.
하는 수 없이 다른 분의 코드를 참고하였는데,
전체 테이블을 조인하는 것이 코드로 보기에는 훨 깔끔해 보인다는 것을 알게 되었다.
또한 아직 having과 where의 차이를 분명히 알지 못하는 상태여서 또 어려웠다.
where은 그룹화 하기 전에 행을 필터링 하는 것,
having은 그룹화 후 그룹을 필터링 하는 것이라는 점을 숙지하고 다시 코드를 짰다.
성공
group by를 썼을 때 select할 수 있는 열들에 대한 직관이 아직 부족하다.
'코딩공부' 카테고리의 다른 글
[프로그래머스] Level.1 / SELECT - 부모의 형질을 모두 가지는 대장균 찾기 (1) | 2024.12.22 |
---|---|
[프로그래머스] Level.1 / SELECT - 특정 형질을 가지는 대장균 찾기 (0) | 2024.12.22 |
[프로그래머스] Level.3 / SELECT - 대장균들의 자식의 수 구하기 (0) | 2024.12.22 |
[HackerRank] SQL / Basic Join / Easy / Average Population of Each Continent (1) | 2024.12.22 |
[HackerRank] SQL / Basic Join / Easy / African Cities (0) | 2024.12.18 |