SQL30 [solvesql - day 7] 기증품 비율 계산하기 https://solvesql.com/problems/ratio-of-gifts/ https://solvesql.com/problems/ratio-of-gifts/ solvesql.com-- 'artworks' 테이블에서 'gift'와 관련된 작품의 비율을 계산SELECT ROUND( -- 'credit' 컬럼에 'gift'라는 단어가 포함된 작품의 개수를 -- 전체 작품의 개수로 나누고 100을 곱하여 비율을 계산 COUNT(CASE WHEN credit LIKE '%gift%' THEN 1 END) * 100.0 / COUNT(*), 3 -- COUNT(CASE WHEN credit LIKE '%gift%' THEN 1 END) : .. 2025. 1. 10. [solvesql - day 6] 게임을 10개 이상 발매한 퍼블리셔 찾기 https://solvesql.com/problems/publisher-with-many-games/ https://solvesql.com/problems/publisher-with-many-games/ solvesql.com-- 10개 이상의 게임을 발행한 회사 이름(name)을 조회SELECT B.name -- 발행사(회사)의 이름FROM games AS A -- 게임 정보가 저장된 테이블JOIN companies AS B -- 회사 정보가 저장된 테이블ON A.publisher_id = B.company_id -- 게임 테이블의 발행사 ID와 회사 테이블의 회사 ID를 연결GROUP BY A.publis.. 2025. 1. 10. [solvesql - day 5] 언더스코어(_)가 포함되지 않은 데이터 찾기 https://solvesql.com/problems/data-without-underscore/ https://solvesql.com/problems/data-without-underscore/ solvesql.com-- 'ga' 테이블에서 페이지 위치(page_location)가 특정 조건을 만족하는 고유한 값만 조회SELECT DISTINCT page_location -- 페이지의 URL 또는 위치를 나타내는 열FROM ga -- Google Analytics 데이터가 저장된 테이블WHERE page_location NOT LIKE '%\_%' ESCAPE '\' -- 페이지 위치에 밑줄(_) 문자가 포함되지 않은 행만 선택.. 2025. 1. 10. [solvesql - day 4] 지자체별 따릉이 정류소 개수 세기 https://solvesql.com/problems/count-stations/ https://solvesql.com/problems/count-stations/ solvesql.com-- 지역별(local)로 정류소(station) 수를 계산하고, 정류소의 개수(num_stations)로 정렬하여 출력SELECT local, -- 지역 이름 COUNT(local) AS num_stations -- 해당 지역의 정류소 수를 계산하여 'num_stations'로 표시FROM station -- 정류소 정보가 저장된 테이블GROUP BY local -- 지역별로 데이터를 그룹화ORDER BY .. 2025. 1. 10. [solvesql - day 3] 제목이 모음으로 끝나지 않는 영화 https://solvesql.com/problems/film-ending-with-consonant/ https://solvesql.com/problems/film-ending-with-consonant/ solvesql.com-- 영화 제목(title)을 조회-- 조건: 등급이 'R' 또는 'NC-17'이고, 제목의 마지막 글자가 모음(A, E, I, O, U)이 아닌 영화SELECT title -- 영화 제목FROM film -- 영화 데이터가 저장된 테이블WHERE (rating = 'R' OR rating = 'NC-17') -- 등급이 'R' 또는 'NC-17'인 영화만 선택 AND SUBS.. 2025. 1. 10. [solvesql - day2] 펭귄 조사하기 https://solvesql.com/problems/inspect-penguins/ https://solvesql.com/problems/inspect-penguins/ solvesql.com-- 각 섬과 펭귄 종(species)별로 데이터를 그룹화하여 조회SELECT species, -- 펭귄의 종 (species) island -- 펭귄이 발견된 섬 (island)FROM penguins -- 펭귄 데이터가 저장된 테이블GROUP BY island, -- 섬을 기준으로 그룹화 species -- 같은 섬 내에서 펭귄의 종별로 그룹화ORDER BY .. 2025. 1. 10. 이전 1 2 3 4 5 다음