sql/Advent of SQL 2024
SQL 문제 풀이 챌린지(7/25) - 기증품 비율 계산하기
gooreumsea
2024. 12. 7. 08:11
저작권 문제로 인해, 직접 작성한 쿼리문만 공개.
7. 기증품 비율 계산하기
https://solvesql.com/problems/ratio-of-gifts/
WITH gift as (
SELECT
count(*) as gift_count
FROM artworks
WHERE LOWER(credit) REGEXP 'gift'
)
SELECT ROUND((SELECT gift_count FROM gift)/count(*)*100, 3) AS ratio
FROM artworks
*** 대소문자 구분 필수