[MEDIUM] Top Competitors
·
SQL/hacker rank
Top Competitors | HackerRank Query a list of top-scoring hackers. www.hackerrank.com 문제 조건 2개 이상의 챌린지에서 만점을 받은 참가자의 이름과 id를 출력하시오 만점을 받은 챌린지의 개수를 기준으로 내림차순 -> id 오름차순 문제 풀이 select h.hacker_id, h.name from submissions s inner join hackers h on s.hacker_id = h.hacker_id inner join challenges c on s.challenge_id = c.challenge_id inner join difficulty d on c.difficulty_level = d.difficulty_level whe..
[MEDIUM] The Report
·
SQL/hacker rank
The Report | HackerRank Write a query to generate a report containing three columns: Name, Grade and Mark. www.hackerrank.com 문제 조건 이름, 등급, 점수의 세 개의 열이 포함된 보고서를 출력하시오. 8 보다 낮은 등급을 받은 학생들의 이름은 출력하지 않습니다. 정렬 순서는 아래와 같습니다 : 등급을 기준으로 내림차순 -> 이름을 알파벳 순으로 정렬 -> 점수를 기준으로 오름차순 문제 풀이 select (case when g.grade < 8 then Null else s.name end) as name, g.grade, s.marks from students s join grades g on s.mark..
[EASY] Weather Observation Station 8
·
SQL/hacker rank
Weather Observation Station 8 | HackerRank Query CITY names that start AND end with vowels. www.hackerrank.com 문제 조건 a,e,i,o,u로 시작하면서 끝나는 city 이름을 유니크하게 출력하시오. 문제 풀이 select distinct city from station where city regexp '^[a,e,i,o,u]' and city regexp '[a,e,i,o,u]$'
[EASY] Weather Observation Station 7
·
SQL/hacker rank
Weather Observation Station 7 | HackerRank Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. www.hackerrank.com 문제 조건 끝 글자가 a,e,i,o,u를 가지는 city 이름을 유니크하게 출력하시오 문제 풀이 # solution 1 select distinct city from station where city regexp '[a,e,i,o,u]$' # solution 2 select distinct city from station where city like '%a' or city like '%e' or city like '%i' or city like '%o' or..
[EASY] Weather Observation Station 6
·
SQL/hacker rank
Weather Observation Station 6 | HackerRank Query a list of CITY names beginning with vowels (a, e, i, o, u). www.hackerrank.com 문제 조건 a,e,i,o,u로 시작되는 city의 이름을 출력하시오 문제 풀이 # solution 1 select city from station where left(city,1) in ('a','e','i','o','u') # solution 2 select city from station where substr(city,1,1) in ('a','e','i','o','u')
[Medium] Weather Observation Station 20
·
SQL/hacker rank
Weather Observation Station 20 | HackerRank Query the median of Northern Latitudes in STATION and round to 4 decimal places. www.hackerrank.com 문제 조건 북부 위도(LAT_N)의 중앙값을 출력하시오 문제 풀이 WITH TEMP AS( SELECT LAT_N, PERCENT_RANK() OVER(ORDER BY LAT_N) AS PERCENT FROM STATION) SELECT ROUND(LAT_N,4) FROM TEMP WHERE PERCENT = 0.5
[Medium] Weather Observation Station 19
·
SQL/hacker rank
Weather Observation Station 19 | HackerRank Query the Euclidean Distance between two points and round to 4 decimal digits. www.hackerrank.com 문제 조건 두 점 사이의 거리를 유클리드 거리 공식을 활용하여 출력하시오. 문제 풀이 SELECT ROUND( SQRT( POWER((MAX(LAT_N) - MIN(LAT_N)),2) + POWER((MAX(LONG_W)-MIN(LONG_W)),2) ),4 ) FROM STATION
[Easy] Weather Observation Station 4
·
SQL/hacker rank
Weather Observation Station 4 | HackerRank Find the number of duplicate CITY names in STATION. www.hackerrank.com 문제 조건 전체 city 수와 고유한 city 수의 차이를 구하시오 문제 풀이 SELECT (COUNT(CITY) - COUNT(DISTINCT CITY)) FROM STATION