4
I need help to elaborate a query that selects only 24 records per day.
For example:
Day 1: 100 records
Day 2: 50 records
Day 3: 34 records
I want to take only 24 of each day: 1, 2 and 3...(in this example I would add: 72 records)
SELECT date_format(hora,'%d/%m/%Y'), SUM(ponto) FROM `pontos` WHERE user = "teste" AND hora >= '2019-08-20' AND hora < NOW()
*As it stands, my query brings the sum of all records
What’s the best way to do that?
Charles, you want to pick up only 1 value an hour, is that it? type, take the time value 00:00 of the day, then the time value 01:00 of the day and so until give the 24 hours and add up, this is it?
– JassRiver
How do you know that the value 170 is not the result of the 24 records? What is in the column "point"?
– Sam
has the value 1 (ONE), where I want to catch 24 points each day
– Charles Fay
in one day the guy can do as many points as he wants (more than MIL), but I want to catch only 24 per day
– Charles Fay
@Heathcliff yes, this is a solution that solves too, because picking 1 point per hour I will have the 24 of each day.
– Charles Fay
@Sam believes that the NOW command considers the time of the record, where today’s records (as per print) entered at a time shorter than the NOW time
– Charles Fay
I posted an updated reply now. See if it solves.
– Sam