Group By days interval (aging type) I would lIke to have Mysql group by days interval for example group by every 20 days from current day, like 1 - 20, 21 - 40, 41 - 60 and son on up to lets 120 days. The user can choose the days interval and up to how many days
select floor(days / 20) as daygroup, count(*)
from mytable
group by daygroup