Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2012
    Posts
    31

    Unanswered: applying RAND to a few columns of total result set

    Hi- trying to figure out how to use RAND.
    I am building a temporary table then applying RAND to the result set to pull back a sample. I have a total of 10 fields, but I only want to apply RAND to 3 of the ten columns, is there an easy way to do that?
    Here is my last statement:

    Select CaseType,ServiceType,AuthorizationType,ReviewType, CaseReferenceNum,
    ServiceBeginDt,ServiceEndDt,DenialType,MemberID,Re portingCategory, RAND() as RID
    FROM Session.TMR_Audit
    ORDER BY RID
    FETCH FIRST 125 ROWS ONLY

    I need to pull back all of these fields. But applying RAND to all of them isn't making my selection complete enough. I need to have a good selection of ServiceType, ReviewType, and DenialType. Do I need to do a sub query? Or can I apply RAND to just those three columns, leaving in the remaining columns?

    Thanks for your help.
    Laura

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    What DB2 version and OS are you using? You may be able to use the Bernouli sampling function to get what you want.


    Andy

Posting Permissions

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