Link to home
Start Free TrialLog in
Avatar of Bob Schneider
Bob SchneiderFlag for United States of America

asked on

Weighted Randomizing

I have a series of 12 running events that I am giving "featured event" status.  The problem is that some of them are coming up this spring and some are not coming up until the fall.  I would like to find the most efficient way to pull their data "randomly" with extra emphasis given to the events that happen soonest.  Not that I would not have the others appearing...just that they would have a lower likelihood.  

With no weighting I was doing this:
sql = "SELECT FeaturedEventsID, EventName, EventDate, Location, WebURL, Descr, BlockImage, Views FROM FeaturedEvents WHERE (EventDate BETWEEN '" & Date 
sql = sql & "' AND '" & Date + 360 & "') AND Active = 'y' ORDER BY NewID()"

Open in new window


I am looking at a process that would select from 1 to 5 of these events as indicated above and be light on the processing.
Avatar of Máté Farkas
Máté Farkas
Flag of Hungary image

Not enough information. Please provide sample data and sample expected output. Thanks.
Avatar of Bob Schneider

ASKER

I am attaching a file of the data as it stands right now.  I want to pull 1 to 5 of these out "randomly" but I want to give more weight to those that are coming up sooner than those that re coming up later.  And I need it to process as quickly as possible because there is a significant amount of traffic during high peak site usage, which is when these will be appearing most often.featured_events.docx
SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm getting this message in  sql server when I try to run a view with this: Invalid parameter 1 specified for datediff
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect!  Thank you!!!