Mysql query with grouping by day and time range

0

Good afternoon. I am putting together a page with reports based on the amount of sales a bar made.

There is only one problem. I need to generate a sales report per day until I got it done by grouping "SELECT count(id) total, DATE(data_abertura) abertura from vendas group by abertura limit 15";

But this is coming back wrong for the following reason that the bar opens day 19 for ex and will only close day 20 so a command can be opened day 20 midnight and a half being the bar opened on the 19th and this sale should be computed as day 19.

Any tips on logic or query how to solve this impasse?

    
asked by anonymous 19.09.2017 / 21:10

0 answers