본문 바로가기
728x90

HackerRank5

[HackerRank] Weather Observation Station 13 문제링크https://www.hackerrank.com/challenges/weather-observation-station-13/problem?isFullScreen=true Weather Observation Station 13 | HackerRankQuery the sum of Northern Latitudes having values greater than 38.7880 and less than 137.2345, truncated to 4 decimal places.www.hackerrank.com 1. 핵심ROUND(컬럼명, 숫자) - 반올림 VS TRUNCATE(컬럼명, 숫자) - 버림`ROUND()`과 `TRUNCATE()`은 SQL에서 숫자 값을 조작하는 데 사용.. 2024. 4. 24.
[HackerRank] Top Earners 문제링크https://www.hackerrank.com/challenges/earnings-of-employees/problem?isFullScreen=true Top Earners | HackerRankFind the maximum amount of money earned by any employee, as well as the number of top earners (people who have earned this amount).www.hackerrank.com 1. 핵심total_earning을 계산 > total_earning 기준 group by > total_earning 기준 내림차순 정렬 > limit 1을 활용해 가장 큰 total_earning 추출 > count(*)를 통해서 가장 .. 2024. 4. 24.
[HackerRank] The Blunder 문제링크https://www.hackerrank.com/challenges/the-blunder/problem?isFullScreen=true1. 핵심[실제 급여의 평균]과 [0을 뺀 잘못된 급여의 평균]의 차이를 반올림하기AVG: 급여의 평균을 구하기 위해서 사용된 함수REPLACE(컬럼명, "0", ""): "0"을 공백으로 대체하기 위해 사용된 함수CEIL(컬렁명): 반올림발생한 문제: "0"으로 하면 정답 / '0'으로 하면 오답SQL에서는 보통 ' '을 사용하는데 " "만 정답이 되는 이유를 모르겠다. 다음은 AI의 답변이다. 이 질문에서 언급된 SQL 쿼리에 대한 문제는 문자열 리터럴을 표시하는 데 사용되는 인용 부호의 차이에서 발생합니다. SQL 표준에서는 문자열 리.. 2024. 4. 23.
[HackerRank] Type of Triangle 문제링크 https://www.hackerrank.com/challenges/what-type-of-triangle/problem?isFullScreen=true Type of Triangle | HackerRank Query a triangle's type based on its side lengths. www.hackerrank.com 1. 핵심 CASE 문 CASE WHEN 조건1 THEN 값1 WHEN 조건2 THEN 값2 ELSE 값3 END AS 컬럼 파이썬에서 'if-elif 문'과 동일한 구조이다. 조건1 확인 후에 조건2로 넘어가며 조건1의 상태는 값1로 출력이 되며, when문 안에서 만족하지 못하면 else의 값이 나온다. 그래서 조건을 잘 설정해야지 코드가 안 길어진다. 이 문제의 .. 2024. 4. 10.
[HackerRank] Weather Observation Station 5 문제링크 https://www.hackerrank.com/challenges/weather-observation-station-5/problem?isFullScreen=true Weather Observation Station 5 | HackerRank Write a query to print the shortest and longest length city name along with the length of the city names. www.hackerrank.com 1. 핵심 도시의 이름이 가장 긴 도시와 짧은 도시를 각각 1개씩 출력 length: 문자열의 길이 측정 length를 기준으로 내림차순 & 오름차순 정렬하고 limit 1을 사용하여 가장 짧은 길이, 가장 긴 길이를 가져온다. 길이가.. 2024. 4. 6.
728x90
반응형