对于 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
postgresql-distinct on理解-LMLPHP
 postgresql-distinct on理解-LMLPHP
 
 

http://blog.csdn.net/luojinbai/article/details/45078809

05-04 05:42