Fun with RAND()

  • Dave62

    SSCertifiable

    Points: 6224

    Comments posted to this topic are about the item Fun with RAND()

  • Koen Verbeeck

    SSC Guru

    Points: 258870

    Great question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • This was removed by the editor as SPAM

  • RKaram

    SSCommitted

    Points: 1518

    Smart question :-):-)

    thank you Dave

    rabih

    rkaram

  • palotaiarpad

    SSCarpal Tunnel

    Points: 4726

    I hate myself not to read the relation correctly! 😀

  • SqlMel

    SSCrazy

    Points: 2891

    Very good question. Thanks.

    I almost got it wrong but I realized in time that the loop had a "<" and not "<="

    ---------------
    Mel. 😎

  • Ed Wagner

    SSC Guru

    Points: 286951

    SqlMel (11/5/2014)


    Very good question. Thanks.

    I almost got it wrong but I realized in time that the loop had a "<" and not "<="

    That's what got me. Need more coffee.

  • alvertorave

    Newbie

    Points: 9

    I think the answer is wrong, you can only have 1 row, but you can execute the select 0 to 9 times returning a single row.

  • akljfhnlaflkj

    SSC Guru

    Points: 76202

    Nice question, thank you.

  • freeheel

    SSCrazy

    Points: 2404

    alvertorave (11/5/2014)


    I think the answer is wrong, you can only have 1 row, but you can execute the select 0 to 9 times returning a single row.

    my thought exactly. i got it right, but ...

  • Brian.Klinect

    Mr or Mrs. 500

    Points: 592

    I forgot RAND() was exclusive. So we can get .99999..., which multiplies to 9.999999..... I take it then that storing a floating point number as an integer just truncates in SQL?

  • stephen.long.1

    SSCrazy

    Points: 2568

    Nice question, Dave, and a good explanation. Thanks!

  • Dana Medley

    SSCertifiable

    Points: 6764

    Ed Wagner (11/5/2014)


    SqlMel (11/5/2014)


    Very good question. Thanks.

    I almost got it wrong but I realized in time that the loop had a "<" and not "<="

    That's what got me. Need more coffee.

    Almost got me too. Thanks for the question.



    Everything is awesome!

  • david.gugg

    SSCertifiable

    Points: 5599

    Fun questions, thank you.


    [font="Tahoma"]Personal blog relating fishing to database administration:[/font]

    [font="Comic Sans MS"]https://davegugg.wordpress.com[/url]/[/font]

  • Mike Hays

    SSCommitted

    Points: 1871

    Interesting Question, I ran it a couple of time to see the different results...

Viewing 15 posts - 1 through 15 (of 28 total)

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