back

Mysql count the number of rows returned with group by or having

If you want to count the number of rows returned from a mysql query, you can just use select count(*) from (the query that you want to know how many rows it has) as temp;

For example, we might do something like:

1
2
3
4
select count(*) from 
  (select count(account_id) from page_views
  group by account_id
  having count(account_id) > 100) as temp;

August 27, 2009