Group by date when using datetime datatype. In this snippet the grouping is used to pull out monthly statistics. The query is pretty much self explanatory. Group by in mysql can help you to bring your work with data to queries, thus avoiding creating multiple queries and working on your data in code. In production you could move dates from SELECT to GROUP BY, this way you can test your results.
Source code viewerProgramming Language: MySQL