[프로그래머스 SQL 고득점 Kit] GROUP BY: 년, 월, 성별 별 상품 구매 회원 수 구하기

jieunee·2023년 4월 1일
0

🤔 문제


✅ 정답

SELECT YEAR(SALES_DATE) AS YEAR, MONTH(SALES_DATE) AS MONTH, GENDER, COUNT(DISTINCT A.USER_ID) AS USERS
FROM USER_INFO AS A JOIN ONLINE_SALE AS B ON A.USER_ID = B.USER_ID
WHERE GENDER IS NOT NULL
GROUP BY YEAR, MONTH, GENDER
ORDER BY YEAR, MONTH, GENDER
profile
Back-End Developer 🌱

0개의 댓글