I want to count the rows in several date ranges (i.e: last hour, today, this week, last 30 days) from a given table.
I need to know how many entries are in this time/date periods to be able to tell if a given user has reach the limit for each one of this ranges. For instance, a user can have max 300 entries one month but with a (hourly/daily/weekly/monthly) limit.
So far I'm trying with a subquery approach using a SELECT CASE
similar to this one: group by range in mysql
Which should be the best way of doing this?