I have a table (tbl_people), in this table I have a datetime field I want to group and count the records in groups of 10 years... The result should be something like:
select CONCAT(FLOOR(YEAR(from_unixtime(TIMESTAMP))/10)*10,'-',(FLOOR(YEAR(from_unixtime(TIMESTAMP))/10)*10)+9) as year , count(ID) from
TABLE group by FLOOR(YEAR(from_unixtime(TIMESTAMP))/10)*10;