[MySQL] 시간대 별 사용자수 구하기 쿼리

갓김치·2022년 6월 27일
0

DB

목록 보기
1/1

상황

  • 로그 테이블에서 유저 사용이 적은 시간대 찾기

쿼리

select hour(a.created) as hour,
	   count(a.created) as cnt
from log a
left outer join user b on (a.username = b.token)
where b.role = 'USER'
  and a.created >= '2022-05-28'
group by hour
order by hour asc;
profile
갈 길이 멀다

0개의 댓글