현재달 mysql

기록지·2021년 12월 7일
0
  1. between 사이에 넣을때
    DATE_ADD(CURDATE(), INTERVAL 0 MONTH)
  2. 그밖에 상황
select
 
    DATE_FORMAT(컬럼명, '%Y-%m') as monthDate
    , count(*) as onlineCount
 
from
 
    (select * from tbl_counsel where cs_type = '1') as x
 
where
 
    1=1
 
and
 
    (select DATE_FORMAT(DATE_ADD(CURDATE(), INTERVAL 0 MONTH), '%Y-%m') = DATE_FORMAT(컬럼명, '%Y-%m'))
 
group by
 
    monthDate desc

출처: https://chobopark.tistory.com/114

0개의 댓글