Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Select Random Record by Priority

Author  Topic 

wingsaga
Starting Member

2 Posts

Posted - 2002-05-24 : 07:49:31
If I have a table like this:

[Name],[Opportunity]
Peter, 3
David, 5
John, 2
Dick, 0
Mary, 9

How can I random select a record according to the Opportunity value? That means Mary will be the highest opportunity to be selected and Dick will be the lowest.

Thank you for your help and sorry for my poor English.




Edited by - merkin on 05/24/2002 08:27:23

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-05-24 : 08:42:10
I believe you've left out some detail in your question. Let me restate it and see if I've correctly inferred what you're trying to accomplish.

You want a pseudorandom selection of name, weighted by the opportunity column but with an element of randomness.

If that's the case, you'll need to tell us what kind of scale is represented by Opportunity. Is it linear? ( is an opportunity of 3 exactly 3 times more likely to be selected than an opportunity of 9? )


quote:

If I have a table like this:

[Name],[Opportunity]
Peter, 3
David, 5
John, 2
Dick, 0
Mary, 9

How can I random select a record according to the Opportunity value? That means Mary will be the highest opportunity to be selected and Dick will be the lowest.

Thank you for your help and sorry for my poor English.




Edited by - merkin on 05/24/2002 08:27:23



setBasedIsTheTruepath
<O>
Go to Top of Page

wingsaga
Starting Member

2 Posts

Posted - 2002-05-24 : 10:29:47
I don't sure what kind of scale I should use but I think your method of using linear may suit my case. If I use linear, what and how should I do?

Thank you for your reply.

Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2002-05-24 : 10:31:42
How about something like this: http://www.sqlteam.com/item.asp?ItemID=802

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page
   

- Advertisement -