Groupby and Having statement - AwesomeNine/Database GitHub Wiki
Examples
// select * from wp_users group by id
$table->groupBy( 'id' )->get();
// select count(id) as total, post_id from phpunit where post_id > 10 group by post_id having count(id) > 25
$table->selectCount( 'id', 'total' )
->select( 'post_id' )
->whereIn( 'post_id', '>', 10 )
->groupBy( 'post_id' )
->having( 'count(id)', '>', 25 );