본문 바로가기
728x90

SQL28

[프로그래머스] 특정 세대의 대장균 찾기 문제링크https://school.programmers.co.kr/learn/courses/30/lessons/301650 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr1. 핵심- WITH RECURSIVE [] AS ( ) 에 대한 이해!! (디버깅하면서 이해한거라 틀릴 수 있음)- non recursive 부분 : tree 테이블의 기초가 되는 부분이다.-- non recursive 부분 : tree 테이블의 기초가 되는 부분이다.-- ECOLI_DATA 에서 PARENT NULL 제외한 것.-- ID, PARENT_ID, GE 의 기초가 세팅select.. 2024. 5. 2.
[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] 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.
[SQL] 우유와 요거트가 담긴 장바구니 문제링크 https://school.programmers.co.kr/learn/courses/30/lessons/62284 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 핵심 교집합을 활용한 풀이 방법1. milk, yogurt 테이블을 각각 만들어서 inner join하는 풀이 + inner join의 경우 중복된 id를 처리하기 위해서 distinct 방법2. 집합연산사 intersect를 사용해서 우유와 요거트가 모두 있는 id 구하기 2. 코드(MySQL) -- 코드를 입력하세요 # 우유와 요거트 동시 구입한 장바구니 # 장바구니의 id 조회.. 2024. 2. 12.
728x90
반응형