X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 47680D1BAA3 for ; Thu, 11 Mar 2004 05:31:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 21608-04 for ; Thu, 11 Mar 2004 01:31:38 -0400 (AST) Received: from millenium.mst.co.jp (unknown [210.230.185.241]) by svr1.postgresql.org (Postfix) with ESMTP id 86444D1BA68 for ; Thu, 11 Mar 2004 01:31:36 -0400 (AST) Received: from mst1x5r347kymb (lc12114 [192.168.1.114]) by millenium.mst.co.jp (8.11.6p2/3.7W) with SMTP id i2B5VPv28522; Thu, 11 Mar 2004 14:31:25 +0900 Message-ID: <009301c4072a$19b28fd0$7201a8c0@mst1x5r347kymb> From: "Iain" To: "Enver ALTIN" Cc: References: <1078937297.29628.12.camel@enver.office.frontsite.com.tr> <20040310190250.GA6629@wolff.to> Subject: Re: randomized order in select? Date: Thu, 11 Mar 2004 14:31:26 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/127 X-Sequence-Number: 17226 If you have a lot of tips, you could create a unique indexed tip number column. Select the highest tip number using: select tip_number from tips order by tip_number desc limit 1; Then generate a random number and select using that tip_number. Of course, you would have to allow for the possibility of missing tip numbers, by repeating the random number generation/read sequence until you find something. Since the tip_number isn't the PK of the table, you can regenerate the tip numbers to eliminate holes from deletions any time you like. Just reset the sequence to 1 and update all rows with the nextval(tipnumber_seq). Sounds like a lot of work to me though...