[Leetcode] 1280. Students and Examinations
·
SQL
Write a solution to find the number of times each student attended each exam.Return the result table ordered by student_id and subject_name.학생이 본 시험 횟수를 계산하는 문제. Explanation: The result table should contain all students and all subjects. Alice attended the Math exam 3 times, the Physics exam 2 times, and the Programming exam 1 time. Bob attended the Math exam 1 time, the Programming exam 1 time..
[HackerRank] Weather Observation Station20: Median(중앙값) 구하기
·
SQL
안녕하세요 오늘도 계속해서 HackerRank 문제를 정리해보도록 하겠습니다.이번에 푼 문제는 Weather Observation Station 20이라는 문제였고요.결국 Median(중앙값)을 구하는 문제였습니다.파이썬으로는 간단하게 구할 수 있는 값을 쿼리로 구하려다 보니 상당히 많이 헷갈렸네요. Q. LAT_N 값의 Median 값을 소수점 4째자리까지 반올림하여 나타내시오.A median is defined as a number separating the higher half of a data set from the lower half. Query the median of the Northern Latitudes (LAT_N) from STATION and round your answer to  ..
[HackerRank] Occupations 직업별 피벗 테이블 만들기
·
SQL
안녕하세요!오늘은 해커랭크에 Occupations 문제를 정리해보려 합니다.피봇테이블 형식을 만들 수 있는지에 대한 문제인데, 한번에 해결하진 못하고 검색을 하면서 해결했네요.배운 점들도 많아서 과정을 한번 적어보겠습니다. 문제는 아래와 같습니다. Q. Occupations 테이블에서 Occupation 컬럼을 4개의 컬럼(Doctor, Professor, Singer, Actor) 피봇형식으로 출력하시오. (단, 알파벳 순으로 정렬)Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output s..
[HackerRank] The PADS 안됐던 이유 정리
·
SQL
안녕하세요! 오늘은 해커랭크의 The PADS 라는 문제를 풀어보고 느낀점을 간단하게 정리해보려 합니다.정말 쉬워보이는데 왜 안되는 거지?를 생각하며 해결하는데 정말 오래 걸렸던 문제인데요.(알파벳 실수한건가 싶어 20번은 제출했던 거 같네요,,)문제를 간단히 요약하면 아래와 같습니다.Q. Occupation 테이블에서 다음과 같은 결과를 도출하세요   Soultion쿼리 자체는 쉬운 편이었고 아마 예상컨데 다들 저같이 'Union all'을 사용해 답안을 제출하셨지 않나 싶네요.저도 같은 답만 10번 이상 제출했던 것 같습니다..# 틀린 답( SELECT CONCAT(NAME,'(',LEFT(OCCUPATION,1),')') FROM OCCUPATIONS ORDER BY NAME)UNIO..