title: Redistribute votes while eliminating candidates
body: <p>Consider this thought. I have a ranking choice voting system, where candidates that doesn't meet the threshold are eliminated during different rounds. In this example we have 6 candidates running for two seats in a primary election. At this point we have reached round 4 (with no winner) where candidates 3 and 5 have already been eliminated. In this round candidate 4 is being eliminated and his/hers votes are about to be redistributed to those candidates marked as second or third choice on each ballot where candidate 4 was marked as first choice.</p>
  
  <p>We grab all ballots where candidate 4 is the first choice (which happens to be 4 ballots). They look like this:</p>
  
  <p>Candidate 4:<br>
  4 1 6 3 2 5<br>
  4 3 1 6 2 5<br>
  4 5 6 2 3 1<br>
  4 3 1 5 6 2<br></p>
  
  <p>The redistributed votes are (in bold):<br>
  4 <strong>1</strong> 6 3 2 5<br>
  4 3 <strong>1</strong> 6 2 5<br>
  4 5 <strong>6</strong> 2 3 1<br>
  4 3 <strong>1</strong> 5 6 2<br></p>
  
  <p>Now for my problem: I need to write a MySQL query that grabs these values and counts the number of votes each given candidate recieves through this redistribution. I.e. the result with the MySQL query should look like this:</p>
  
  <p>Candidate 1: 3 votes<br>
  Candidate 6: 1 vote</p>
  
  <p>EDIT: This query need to know that candidates 3 and 5 are already eliminated thus heading for the next column to find any other candidate.</p>
  
  <p>How would I write a MySQL query to get this result?</p>