Advertisement

12.07.2007 at 07:55AM PST, ID: 23008905
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.8

MySQL Query Question - generate a random winner from list of contestants with varying number of entries

Asked by jameswalt in MySQL Server

Tags: , , ,

I have a database of members. Each member has 0 or more entries into a contest, and each day a member can use up to 10 entries to win a prize. I need to generate a random winner from the database using the spread of entries that each member contains.

Here's how I began to approach this problem:
SELECT Sum(IF(entriesremaining>10,10, entriesRemaining)) AS numberOfEntries FROM members

The above query returns the number of entries to be used in today's drawing. Next, I want to choose a random number between 1 and [numberOfEntries]. The problem I have is figuring out which part of the spread this random number belongs to.

I want to start the new query with something like this:
SELECT * FROM members WHERE {this member's entry is the winning random number}

Here's a logicial example:
James has 5 entries
Kelly has 7 entries
Josh has 15 entries

The total number of entries used today is 22 (5+7+10). The random number chosen is 9. James has tickets 1-5, Kelly has tickets 6-12, and Josh has 13-22. Therefore, Kelly wins today's contest.

What kind of query could efficiently figure this out?
Start Free Trial
 
Loading Advertisement...
 
[+][-]12.07.2007 at 07:57AM PST, ID: 20428305

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 08:15AM PST, ID: 20428482

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 08:25AM PST, ID: 20428599

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 08:48AM PST, ID: 20428820

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 08:58AM PST, ID: 20428918

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 08:59AM PST, ID: 20428938

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 09:14AM PST, ID: 20429067

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 09:28AM PST, ID: 20429193

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 09:33AM PST, ID: 20429231

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 09:38AM PST, ID: 20429259

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 09:49AM PST, ID: 20429361

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 10:07AM PST, ID: 20429489

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.07.2007 at 11:25AM PST, ID: 20430067

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MySQL Server
Tags: mysql, random, from, query
Sign Up Now!
Solution Provided By: blckholehorizon
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628