This may be, so to speak, an alternative method of solving my previous problem . Now from the data table pull query:

SELECT day(FROM_UNIXTIME(`t_date`)) as day, COUNT(*) as summ_open FROM table WHERE `t_status`=0 AND month(FROM_UNIXTIME(`t_date`)) = month(now()) GROUP BY day 

At the exit we get the amount for each day. Is it possible to make a request somehow so that he considers the sum of the day and adds up with the sum of the previous day? In order not to resort to the implementation of the means of php, and do everything on mysql?

    1 answer 1

    As an option:

     CREATE TEMPORARY TABLE `simple` SELECT DAY( FROM_UNIXTIME(`t_date`) ) as `day`, COUNT(*) as `summ_open` FROM `table` WHERE `t_status` = 0 AND MONTH( FROM_UNIXTIME(`t_date`) ) = MONTH( now() ) GROUP BY `day`; CREATE TEMPORARY TABLE `recurcive` SELECT * FROM `simple`; SELECT `simple`.`day`, SUM( `recurcive`.`summ_open` ) as `summ_open` FROM `simple`, `recurcive` WHERE `simple`.`day` >= `recurcive`.`day` GROUP BY `day`; 

    Either way:

     SELECT `simple`.`day`, SUM( `recurcive`.`summ_open` ) as `sum_open` FROM ( SELECT DAY( FROM_UNIXTIME(`t_date`) ) as `day` FROM `table` WHERE `t_status` = 0 AND MONTH( FROM_UNIXTIME(`t_date`) ) = MONTH( now() ) GROUP BY `t_date` ) AS `simple` INNER JOIN ( SELECT DAY( FROM_UNIXTIME(`t_date`) ) as `day`, COUNT(*) as `summ` FROM `table` WHERE `t_status` = 0 AND MONTH( FROM_UNIXTIME(`t_date`) ) = MONTH( now() ) GROUP BY `day`; ) AS `recurcive` ON `simple`.`day` <= `recurcive`.`day` GROUP BY `day`