Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2014
    Posts
    294

    Unanswered: SQLSTATE=428F5 when rounding

    Hi,

    How to generate a random numbers in a range of values in db2.
    I tried I can specify the upper limit , i can't specify the lower limit. I want to generate the random numbers between 1 to 10.
    can some one tel me how to work.
    This is what I tried:

    SELECT CAST ( int ( RAND () * LENGTH(109)) AS CHAR(1)) FROM SYSIBM.SYSDUMMY1);
    Last edited by HABBIE; 10-13-14 at 06:22.

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    (RAND()*(upper_limit - lower_limit))+lower_limit

    Andy

  3. #3
    Join Date
    Jul 2014
    Posts
    294
    Thanks Andy

Tags for this Thread

Posting Permissions

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