Random Numbers - DB2 on AS/400

Results 1 to 2 of 2

Thread: Random Numbers - DB2 on AS/400

  1. #1
    Join Date
    Dec 1969

    Default Random Numbers - DB2 on AS/400

    Does anyone knows how to get a Random Number of Record Sets from a DB2 on AS/400. I can get the records from DB2, i can Delete and i can Insert the Records in DB2 on AS/400. But having trouble to get the Random Number of Records (Using a SQL Statement from my HTML Form), No idea about SQL Statement syntax which will get random data from DB2 on AS/400. Please help me.

  2. #2
    Join Date
    Dec 1969

    Default Here is an example

    of returning random records in IBM UDB, however if you have OLAP options installed it should work for you for IBM DB2/AS400 too.<BR><BR>This will return 10 randow records from your matching results.<BR><BR>SELECT empid<BR> ,empname<BR> FROM (SELECT a.* <BR> ,ROW_NUMBER() OVER(ORDER BY RAND()) AS rown<BR> FROM employee a<BR> )AS temp1<BR> WHERE rown &#060;= 10<BR>ORDER BY empid;<BR><BR>Good luck<BR>Pete

Posting Permissions

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