SQL 문제

[solvesql_Level2] 일별 블로그 방문자 수 집계

빙수빈수 2023. 10. 11. 10:34

https://solvesql.com/problems/blog-counter/

 

https://solvesql.com/problems/blog-counter/

 

solvesql.com

[코드]

select event_date_kst as dt, count(DISTINCT user_pseudo_id) as users
from ga
where dt BETWEEN '2021-08-02' and '2021-08-09'
group by dt
order by dt

 

[고찰]

 이번 문제는 날짜별 방문자의 수를 구하는 문제였다. 이때  해당 일자 내 로그 테이블에 이벤트가 하나라도 기록 된 경우 방문자로 집계하기 때문에 중복된 사람이 있을 수 있다. 따라서 count를 해줄 때 중복을 제거해주어야 한다.