dev/DB
-
mysql 일별, 주별, 월별, 기간별 통계 쿼리dev/DB 2019. 1. 11. 14:46
출처http://bluexmas.tistory.com/626 # 일별SELECT DATE(`reg_date`) AS `date`, sum(`value`) FROM test_st GROUP BY `date`; # 주별SELECT DATE_FORMAT(DATE_SUB(`reg_date`, INTERVAL (DAYOFWEEK(`reg_date`)-1) DAY), '%Y/%m/%d') as start, DATE_FORMAT(DATE_SUB(`reg_date`, INTERVAL (DAYOFWEEK(`reg_date`)-7) DAY), '%Y/%m/%d') as end, DATE_FORMAT(`reg_date`, '%Y%U') AS `date`, sum(`value`) FROM test_st GROUP BY dat..