본문 바로가기
728x90

전체 글348

[리트코드] 262. Trips and Users - MySQL https://leetcode.com/problems/trips-and-users/ Trips and Users - LeetCode Can you solve this real interview question? Trips and Users - Table: Trips +-------------+----------+ | Column Name | Type | +-------------+----------+ | id | int | | client_id | int | | driver_id | int | | city_id | int | | status | enum | | request_at | leetcode.com 문제 2013-10-01~2013-10-03 3일간 매일 여행 취소율을 구하라 banned한 사람들.. 2023. 7. 15.
[해커랭크] Weather Observation Station 20 - MySQL https://www.hackerrank.com/challenges/weather-observation-station-20/problem?isFullScreen=true Weather Observation Station 20 | HackerRank Query the median of Northern Latitudes in STATION and round to 4 decimal places. www.hackerrank.com 문제 LAT_N의 중앙값을 구하라 풀이 1 데이터의 개수가 홀수인지 짝수인지에 따라 중앙값을 구하는 방법이 다르다 홀수인 경우 중앙값의 위치는 (N+1)//2 짝수인 경우 중앙의 두 수의 평균 구하기 두 수의 위치 : N//2, (N//2)+1 LAT_N의 순위 구하기 -- 순위, 데.. 2023. 7. 15.
[해커랭크] Ollivander's Inventory - MySQL https://www.hackerrank.com/challenges/harry-potter-and-wands/problem?isFullScreen=true Ollivander's Inventory | HackerRank Help pick out Ron's new wand. www.hackerrank.com 문제 non-evil이고 power와 age가 같다면 coins_needed는 최소여야 한다. id, age, coins_needed, power를 출력하라 power 내림차순, age 내림차순 정렬 풀이 1 우선 power와 age가 같을 때 coins_needed를 가질려면 그룹화를 사용해야 한다. 서브 쿼리를 통해 각각의 경우 가장 작은 coins_needed를 구할 수 있다. 코드 1 SELEC.. 2023. 7. 14.
[해커랭크] Occupations - MySQL https://www.hackerrank.com/challenges/occupations/problem?isFullScreen=true Occupations | HackerRank Pivot the Occupation column so the Name of each person in OCCUPATIONS is displayed underneath their respective Occupation. www.hackerrank.com 문제 Doctor, Professor, Singer, and Actor에 해당하는 사람의 이름을 각 컬럼으로 출력하라 없으면 NULL 이름은 순서대로 풀이 각 직업별 이름 순위 구하기 -> 윈도우 함수 ROW_NUMBER() 사용 SELECT Occupation , Name ,.. 2023. 7. 11.
[프로그래머스] LV4. 입양 시각 구하기(2) - MySQL https://school.programmers.co.kr/learn/courses/30/lessons/59413 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 풀이 각 시간별 개수 세기 문제 : 존재하지 않는 시간이 나타나지 않는다. SELECT HOUR(DATETIME), COUNT(*) FROM ANIMAL_OUTS GROUP BY HOUR(DATETIME) ORDER BY HOUR(DATETIME); 0~6, 20~23 존재하지 않는 시간의 COUNT는 0으로 나와야하니 시간 컬럼을 만들어야겠다 -> 가상 테이블 만들기 https://chae.. 2023. 7. 11.
[리트코드] 185. Department Top Three Salaries - MySQL https://leetcode.com/problems/department-top-three-salaries/ Department Top Three Salaries - LeetCode Can you solve this real interview question? Department Top Three Salaries - Table: Employee +--------------+---------+ | Column Name | Type | +--------------+---------+ | id | int | | name | varchar | | salary | int | | departmentId | int | +-------------- leetcode.com 문제 각 부서의 급여순으로 3등까지 출력하라 같.. 2023. 7. 9.
반응형