test=# SELECT * FROM ( SELECT ROW_NUMBER() OVER (PARTITION By name ORDER BY create_time DESC) AS rownum, name, order_cnt FROM order_tab ) T WHERE T.rownum = 1; rownum | name | order_cnt --------+------+----------- 1 | 李四 | 4 1 | 张山 | 5 (2 rows)