SELECT extract(MONTH from created_at) AS month, extract(YEAR from created_at) AS year FROM users GROUP BY extract(MONTH from created_at), extract(YEAR from created_at) ORDER BY extract(MONTH from created_at), extract(YEAR from created_at)
Đây là hướng dẫn cập nhật
http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
Btw:Đây là SQL chuẩn (ANSI) cũng hoạt động trên MySQL.