There is a table Post in my database which contains posts of different users. What I wanna do is to create an sql query that’ll return as per respective month the number of posts being made each day. Kindly let me know how can i do that generically in one query i can create multiple queries for all days but that is a worst case scenario. So I need expert’s solution to this.
Thanks
Expected output:
(Query counts the number of posts for all the days in a respective month)
Day : Number of posts
1 : 20
2 : 25
3 : 10
4 : 17
…………………….
30 : 6
Table Structure:
ID | postid | post | date
If you want to query for a specific month (say, February) then use this:
Note: Months are returned in number form where the MONTH() function is used.
EDIT: If you’re looking to return counts for EVERY day in a given month, then I’d push you here – a great accepted answer to a similar question: How to get values for every day in a month