https://school.programmers.co.kr/learn/courses/30/lessons/131532
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
Distinct 를 사용해서 중복 아이디를 막아줘야 하는 것이 중요하다.
-- 코드를 입력하세요
SELECT extract(year from sales_date) as year, extract(month from sales_date) as month, u.gender , count(distinct(u.user_id)) as users
from user_info u inner join online_sale o
on u.user_id = o.user_id where extract(year from sales_date)=2022 and (u.gender =1 or u.gender=0 )
group by year, month, gender order by year,month,gender
'SQL' 카테고리의 다른 글
조건에 부합하는 중고거래 상태 조회하기(프로그래머스 SQL) (2) | 2023.11.23 |
---|---|
5월 식품들의 총매출 조회하기(프로그래머스 SQL) (0) | 2023.11.22 |
그룹별 조건에 맞는 식당 목록 출력하기 (프로그래머스 SQL) (0) | 2023.11.22 |
주문량이 많은 아이스크림들 조회하기(프로그래머스 SQL) (1) | 2023.11.22 |