Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004

    Unanswered: Select 5 Random Records

    Anyone know how I can select only 5 random records from an Informix table?

  2. #2
    Join Date
    May 2004
    New York
    Unless you give the order by, there is no guarantee on how you will get the records from the table.

    5 records you can get by executing the following

    select first 5 * from table_name


  3. #3
    Join Date
    Apr 2003
    Phoenix, AZ
    The process that I have used in the past is based upon selecting random ROWID's with the range min(ROWID) and max(ROWID).

    I used a random number routine to generate a random number between the min and the max and then SELECT the row based upon ROWID. HOWEVER, just because you generate a number does not mean that that ROWID exists. So the SELECT statement was something like "SELECT FIRST 1 ... WHERE ROWID >= myrandonmumber"
    Fred Prose

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts