且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从MySQL到PostgreSQL:如何修改此SQL查询?

更新时间:2023-01-22 16:01:00


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) 

这是最新的手册

http: //www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DA TETIME-EXTRACT

Btw:这也是在MySQL上也可以使用的标准(ANSI)SQL。

Btw: This is standard (ANSI) SQL that works on MySQL as well.