PostgreSQL DISTINCT ON

https://stackoverflow.com/questions/3800551/select-first-row-in-each-group-by-group


select DISTINCT ON (creatorid) * from t
where status = '1'
ORDER BY creatorid, createtime desc

根据创建者分组,取每个创建者最早创建的记录。

posted @ 2019-08-26 09:12  JillWen  阅读(215)  评论(0编辑  收藏  举报