Professional Web Applications Themes

generating random numbers - Microsoft SQL / MS SQL Server

How do I generate a random number between 1 and 10? I need to capture information of potential clients and randomly assign them to salespersons. Thanks....

  1. #1

    Default generating random numbers

    How do I generate a random number between 1 and 10?

    I need to capture information of potential clients and
    randomly assign them to salespersons.

    Thanks.
    Jaimee Guest

  2. #2

    Default Re: generating random numbers


    Just a though, why assign them randomly, rather than distributing new clients among the salespeople who have the least clients?


    "Jaimee" <jaimee.cotchergekko.com> wrote in message news:063d01c33f72$e4a24fd0$a301280aphx.gbl...
    How do I generate a random number between 1 and 10?

    I need to capture information of potential clients and
    randomly assign them to salespersons.

    Thanks.

    Damien Laffan Guest

  3. #3

    Default Re: generating random numbers

    Or if you're on SQL 2000 you can just pick a random salesperson in this way:

    UPDATE potential_clients
    SET assigned_sales_person = (SELECT TOP 1 sales_person_id FROM sales_persons
    ORDER BY NEWID())

    The NEWID() function generates GUIDs, which are not designed to be random
    (they are designed to be unique), but for most practical purposes they are.

    I wouldn't by the way assign them randomly, as Damien pointed out. Either
    his method or just using round-robin (assign the client to the sales person
    who has been assigned a client the longest time ago) makes more sense.
    Random is more random and less evenly distibuted than most people think.

    --
    Jacco Schalkwijk MCDBA, MCSD, MCSE
    Database Administrator
    Eurostop Ltd.


    "Jaimee" <jaimeegekko.com> wrote in message
    news:2ae601c33f78$404e6210$a601280aphx.gbl...
    > I don't know -- business decision. But here's how to do
    > it --
    >
    > select convert(int,rand() * (10 - 1) + 1)
    >
    > This will generate a random number between 1 and 9.
    >
    > Thanks.
    >
    >
    > >-----Original Message-----
    > >
    > >Just a though, why assign them randomly, rather than
    > distributing new clients among the salespeople who have
    > the least clients?
    > >
    > >
    > >"Jaimee" <jaimee.cotchergekko.com> wrote in message
    > news:063d01c33f72$e4a24fd0$a301280aphx.gbl...
    > >How do I generate a random number between 1 and 10?
    > >
    > >I need to capture information of potential clients and
    > >randomly assign them to salespersons.
    > >
    > >Thanks.
    > >
    > >.
    > >

    Jacco Schalkwijk Guest

  4. #4

    Default Re: generating random numbers

    This thread is tangenting, but I want to chime in and say "I concur".

    Ideally, if you have a queue of 30 sales reps, and a load of 3000 leads, you
    would want to 'randomly' assign a lead to one within the pool of 30. Then
    decrement the pool to 29 ( removing the lucky winner ) and repeat. Once the
    pool reaches zero, reset the pool back to 30 and loop again.

    "Pure" randomness is tantamount to taking a handful of dimes and tossing
    them straight up in the air. When they land, some will be clustered near
    each other, some will roll off out of sight. Blessed is the sales rep who
    lands in a cluster.

    /Ty


    "Jacco Schalkwijk" <NOSPAMjaccoseurostop.co.uk> wrote in message
    news:uqWv936PDHA.1748TK2MSFTNGP11.phx.gbl...
    > Or if you're on SQL 2000 you can just pick a random salesperson in this
    way:
    >
    > UPDATE potential_clients
    > SET assigned_sales_person = (SELECT TOP 1 sales_person_id FROM
    sales_persons
    > ORDER BY NEWID())
    >
    > The NEWID() function generates GUIDs, which are not designed to be random
    > (they are designed to be unique), but for most practical purposes they
    are.
    >
    > I wouldn't by the way assign them randomly, as Damien pointed out. Either
    > his method or just using round-robin (assign the client to the sales
    person
    > who has been assigned a client the longest time ago) makes more sense.
    > Random is more random and less evenly distibuted than most people think.
    >
    > --
    > Jacco Schalkwijk MCDBA, MCSD, MCSE
    > Database Administrator
    > Eurostop Ltd.
    >
    >
    > "Jaimee" <jaimeegekko.com> wrote in message
    > news:2ae601c33f78$404e6210$a601280aphx.gbl...
    > > I don't know -- business decision. But here's how to do
    > > it --
    > >
    > > select convert(int,rand() * (10 - 1) + 1)
    > >
    > > This will generate a random number between 1 and 9.
    > >
    > > Thanks.
    > >
    > >
    > > >-----Original Message-----
    > > >
    > > >Just a though, why assign them randomly, rather than
    > > distributing new clients among the salespeople who have
    > > the least clients?
    > > >
    > > >
    > > >"Jaimee" <jaimee.cotchergekko.com> wrote in message
    > > news:063d01c33f72$e4a24fd0$a301280aphx.gbl...
    > > >How do I generate a random number between 1 and 10?
    > > >
    > > >I need to capture information of potential clients and
    > > >randomly assign them to salespersons.
    > > >
    > > >Thanks.
    > > >
    > > >.
    > > >
    >
    >

    Ty Guest

Similar Threads

  1. Random Numbers
    By Ricardo in forum PHP Development
    Replies: 12
    Last Post: July 14th, 07:31 PM
  2. getting a list of random numbers
    By Thomas L in forum PHP Development
    Replies: 3
    Last Post: January 3rd, 01:33 PM
  3. Generating random passwords
    By Zhwgnon Flrq in forum ASP.NET Security
    Replies: 2
    Last Post: December 30th, 09:19 PM
  4. Random Numbers - Please help!
    By djmasala.com in forum Macromedia Director Basics
    Replies: 1
    Last Post: August 21st, 09:24 AM
  5. Generating random numbers?
    By Harry Ohlsen in forum Ruby
    Replies: 14
    Last Post: July 31st, 05:23 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139