Tuesday, March 24, 2009

SQL: having count

select * from game g join team_game tg on g.id = tg.game_id group by g.id having count(g.id) > 2


The HAVING clause is used with the GROUP BY clause. It can be used in a SELECT statement to filter the records that a GROUP BY returns.