반응형
https://school.programmers.co.kr/learn/courses/30/lessons/131534?language=mysql
SELECT
YEAR(B.SALES_DATE) AS YEAR,
MONTH(B.SALES_DATE) AS MONTH,
COUNT(DISTINCT(B.USER_ID)) AS PUCHASED_USERS,
ROUND(
COUNT(DISTINCT(B.USER_ID)) / (
SELECT COUNT(1)
FROM USER_INFO
WHERE JOINED <= '2021-12-31'
)
, 1) AS PUCHASED_RATIO
FROM USER_INFO A
JOIN ONLINE_SALE B ON A.USER_ID = B.USER_ID
WHERE A.JOINED BETWEEN '2021-01-01' AND '2021-12-31'
GROUP BY YEAR(B.SALES_DATE), MONTH(B.SALES_DATE)
'알고리즘' 카테고리의 다른 글
[프로그래머스] Lv.3 인사고과 (JS) (0) | 2023.07.01 |
---|---|
[백준] 14243 출근기록2 (C++) (0) | 2023.05.15 |
[백준] 17298 오큰수 (C++) (0) | 2023.04.18 |
[프로그래머스] LV.3 숫자게임 (JAVA) (0) | 2023.04.18 |
[백준] 11000 강의실 배정 (C++) (0) | 2023.04.14 |