In Pervasive PSQL (specifically), using a sql select statement, how can you select a random row from a table that has no numeric IDs?
This seems to work for me using 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()
Which I ran several times and got:
<<<<<<<<<<<<<<<<<<<<<<<<
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.
>>>>>>>>>>>>>>>>>>>>>>>>