以下功能符合PostgreSQL
如果你的表中包含oid字段,可以使用如下语句:
select * from table1 where oid in (select min(oid) from table1 group by name)
而且,你如果有大量的数据,甚至可以在oid上创建一个唯一性的索引,以加快速度。如果你为了效率,创建的是不包含oid字段的表,那么可以使用如下语句:
select * from table1 where textin(tidout(ctid)) in
(select min(textin(tidout(ctid))) from table1 group by name)
但是这样的话,你的这个sql语句的效率可能会差一些。
如果你的表中包含oid字段,可以使用如下语句:
select * from table1 where oid in (select min(oid) from table1 group by name)
而且,你如果有大量的数据,甚至可以在oid上创建一个唯一性的索引,以加快速度。如果你为了效率,创建的是不包含oid字段的表,那么可以使用如下语句:
select * from table1 where textin(tidout(ctid)) in
(select min(textin(tidout(ctid))) from table1 group by name)
但是这样的话,你的这个sql语句的效率可能会差一些。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货