I have the following table:
+----+---------------------+-------------+-----------------+
| id | stat_time | reads | writes |
+----+-
You want to convert the stat_time
to a day to do this. The method depends on the database. Here is one way:
SELECT cast(stat_time as date) as stat_day, SUM(reads), SUM(writes)
from this_table
GROUP BY cast(stat_time as date)
order by stat_day;
Here are some other approaches (for MySQL and Oracle):
SELECT date(stat_time) as stat_day, SUM(reads), SUM(writes)
from this_table
GROUP BY date(stat_time)
order by stat_day;
SELECT trunc(stat_time) as stat_day, SUM(reads), SUM(writes)
from this_table
GROUP BY trunc(stat_time)
order by stat_day;
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 ';