postgresql-distinct on理解

对于 select distinct on , 可以利用下面的例子来理解:
create table a6(id integer, name varchar(10));
insert into a6 values(1, ' 001');
insert into a6 values(1, '002');
insert into a6 values(2, '003');
insert into a6 values(2, '004');
select distinct on (id) id, name from a6;
id | name
---+--------
1 | 001
2 | 003
(2 rows)
 类似于窗口函数row_number

 

 
 
 
http://blog.csdn.net/luojinbai/article/details/45078809
posted @ 2019-01-03 17:22  月图灵  阅读(3431)  评论(0编辑  收藏  举报