Is it possible to group rows per day stored in a timestamp?

I'm not sure if this is even within MySQL, to be honest, or if some php is needed for data analysis. But if it's ... some kind of stored procedure is probably necessary.

I have a table that stores rows with timestamp and quantity.

My request is dynamic and will be executed based on a user-specified date range. I would like to get SUM () of amounts for each day in a table that is between a date range. , including 0 if there are no entries for this day

Something because of ...

SELECT 
   CASE
     WHEN //there are entries present at a given date
       THEN SUM(amount)
     ELSE 0
   END AS amountTotal,
   //somehow select the day
   FROM  thisTableName T
   WHERE T.timeStamp BETWEEN '$start' AND '$end'
   GROUP BY //however I select the day

These are two parators ...
Is there a way to select the section of the returned column? How some kind of regex in mysql?
Is there a way to return 0 for dates without strings?

+3
1
select * from thisTableName group by date(created_at);

SELECT id, count(id) as amountTotal
FROM thisTableName
WHERE timeStamp BETWEEN '$start' AND '$end'
GROUP BY DATE(timeStamp);

: .

+2

Source: https://habr.com/ru/post/1730442/


All Articles