Search MySql records Group By Year from DateTime
I am working with Mobile Ad networking site for one of my client and I wanted to get the yearly records from DateTime field. Actually I am transferring hourly data into different table to reduce load time of reporting page. For this, i need to combine records by yearly from date or date time field. You can do this in two ways. Here is the way to achieve this.
GROUP BY YEAR(datetime)
GROUP BY EXTRACT(YEAR FROM datetime)
Let me know if you find any problem.