2
I have the following table:
+------------+--------------+-------------------+
| ID | vacina | data |
+------------+--------------+-------------------+
| 1 | Cinomose |2017-07-10 10:11:15|
+------------+--------------+-------------------+
| 2 | Coronavirose |2017-08-09 10:11:15|
+------------+--------------+-------------------+
| 3 | Vermifugo |2017-10-10 10:11:15|
+------------+--------------+-------------------+
| 4 | Anti-pulgas |2017-07-25 10:11:15|
+------------+--------------+-------------------+
| 5 | Anti-rábica |2017-06-06 10:11:15|
+------------+--------------+-------------------+
| 6 | V4 |2017-07-10 10:11:15|
+------------+--------------+-------------------+
I would like a query that returns me the amount of vaccines you have on the day compared to the current month, considering that today is 2017-07-25
. For example:
+------------+-------------------+
| qnd | data |
+------------+-------------------+
| 2 |2017-07-10 10:11:15|
+------------+-------------------+
| 1 |2017-07-25 10:11:15|
+------------+-------------------+
My initial initiative was this way below:
SELECT COUNT(*) as qnd, datetime_start as date FROM `tbl_delivery` GROUP BY datetime_start
But so does the process of counting and grouping but returns data of every month that are contained in the table.
Try using that question from: how to search for records saved in the current week, but the grouping did not function.
What would be the most viable way to rescue all data of the current month grouped by date?
Although the other answer is also valid showing the comparison in relation to time, I will validate this by not having to indicate the interval of dates for comparison, in which Dnick use
BETWEEN
. Vlw.– viana