SQL command to sum by day/month

前端 未结 2 789
有刺的猬
有刺的猬 2021-01-07 05:08

I have the following table:

+----+---------------------+-------------+-----------------+
| id | stat_time           |       reads |          writes |
+----+-         


        
2条回答
  •  悲哀的现实
    2021-01-07 05:25

    let's assume you have a column with name D-DATE_START so

    $query = 'SELECT cast(D_DATE_START as date) as stat_day ,'
            .'sum(I_REV_MODEL) as totalDayRevenu '
            .'FROM t_show WHERE FK_MODEL=136 '
            ."and t_show.D_DATE_START between '".$after."' and '".$before."'"
            .' GROUP BY cast(D_DATE_START as date) '
            .' ORDER BY stat_day ';
    

提交回复
热议问题