Count between dates and operate between rows - SQL I try to count elements between dates and operate between rows agnostically. As an example, suppose the month starts from day 2 until day 2 of next month. The table has fields {timestamp, status} and the status field has 3 different types. I do not know how to make it count between dates. Also, I would like to have the percentage of statuses.
Thank you for the help sincerely.
WHERE timestamp &gt;= '2021-04-02'
  AND timestamp  &lt; '2021-04-02' + INTERVAL 1 MONTH
  AND status = &quot;done&quot;

(If you need to discuss further, please provide SHOW CREATE TABLE and more details about the desired query.)
And this index may help with performance:
INDEX(status, timestamp)