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)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM