I have a MySQL table for data containing earnings for taxi / uber rides with the following fields:
id
ride_date
ride_earnings
ride_tips
I am trying to get a list of the most "profitable" dates, I can do:
SELECT DATE(ride_date) as d, SUM(ride_earnings+ride_tips) as total, COUNT(id) as ride_count
FROM rides
GROUP by d
ORDER BY total DESC
But I need to group them as all rides from 12pm on one day - 12pm the next day. Thanks in advance!
EDIT: Changed from 12p - 12p to make it more simple
EDIT2: Also, I should have stated this but i will be pulling this data through PHP so I would preferably need it in one statement