Generating Non-uniform Random Numbers with SQL

  • Great post - thanks for sharing - this just saved me a ton of time trying to figure out how to do this on my own!

  • greenantim (10/11/2012)


    Great post - thanks for sharing - this just saved me a ton of time trying to figure out how to do this on my own!

    greenantim - Thanks for joining the party, even if fashionably late!

    Glad the techniques were useful to you.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • Apparently, PhotoBucket changed something on their site.  The missing graphics for Dwain's article may be found at the following link.

    http://s1252.photobucket.com/user/dwaincamps/library/Random%20Numbers?sort=3&page=1

    p.s.  Miss ya, Buddy. You were definitely one of the good guys.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

Viewing 3 posts - 31 through 33 (of 33 total)

You must be logged in to reply to this topic. Login to reply