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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-03-16 : 16:02:50
|
Xyptilon writes "Im using sql server 7 and have the following problem.
I have a table with the following fields
ID URL POINTS
All fields speak for themselves, there are let's say 25.000 rows (thus 25.000 URLs) in the table. Each URL has a different number of points (one point = 1 display) thus I need a solution that one random record is retrieved based on the points, but it still has to be random. For example.
site1 = 3 points site2 = 12 points site3 = 2 points site4 = 123 points
--- solution ---
Storedproc gets the sum of all points thus SUM(points) and gets a random number somehow between MIN = 1 and MAX = SUM(points)..
then I need the stored proc (in a quick way) to find out to which site this number belongs. For example if the random number would be 16, then this would belong to site3 because 3+12 = 15 and thus smaller than 16.. and 3+12+2 = 17 (smaller than 16) which is the site to be displayed.
Of course any suggestions for other approaches are also appreciated.
Sincerely," |
|
|
|
|
|