https://school.programmers.co.kr/learn/courses/30/lessons/131532
정답
-- 코드를 입력하세요
SELECT extract(year from B.SALES_DATE) AS YEAR,
extract(month from B.SALES_DATE) AS MONTH,
A.GENDER, COUNT(DISTINCT B.USER_ID) AS USERS
FROM USER_INFO A RIGHT OUTER JOIN ONLINE_SALE B
ON A.USER_ID = B.USER_ID
WHERE A.GENDER IS NOT NULL
GROUP BY extract(year from B.SALES_DATE),
extract(month from B.SALES_DATE),
A.GENDER
ORDER BY YEAR ASC, MONTH ASC, GENDER ASC
마지막 컬럼에 DISTINCT를 넣어주는것이 포인트였다.
문제풀이 예시를 보면, 1월에 PRODUCT_ID 54와 3을 구매한 USER_ID가 1인 부분은
COUNT를 했을때 2건으로 인식될것이기 때문이다