繁体   English   中英

如何从Pervasive PSQL表中选择随机行

[英]How to select a random row from a Pervasive PSQL table

Pervasive PSQL中 (具体来说),使用sql select语句,如何从没有数字ID的表中选择随机行?

似乎对我使用PSQL v11.30有用。

create table chartest (f1 char (10), f2 char(10), f3 char(10));
insert into chartest values ('a','a','a');
insert into chartest values ('b','b','b');
insert into chartest values ('c','c','c');
insert into chartest values ('d','d','d');
insert into chartest values ('e','e','e');
insert into chartest values ('f','f','f');
select top 1 * from chartest order by newid()

我跑了几次,得到了:

<<<<<<<<<<<<<<<<<<<<<<<<
f1           f2           f3        
==========   ==========   ==========
e            e            e         
1 row was affected.
>>>>>>>>>>>>>>>>>>>>>>>>

<<<<<<<<<<<<<<<<<<<<<<<<
f1           f2           f3        
==========   ==========   ==========
c            c            c         
1 row was affected.
>>>>>>>>>>>>>>>>>>>>>>>>

<<<<<<<<<<<<<<<<<<<<<<<<
f1           f2           f3        
==========   ==========   ==========
b            b            b         
1 row was affected.
>>>>>>>>>>>>>>>>>>>>>>>>

<<<<<<<<<<<<<<<<<<<<<<<<
f1           f2           f3        
==========   ==========   ==========
f            f            f         
1 row was affected.
>>>>>>>>>>>>>>>>>>>>>>>>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM