title: Counting the number of rows with a value greater than or equal to a value from another column in SQL
body: <p>I have a table with two columns: a couple id and a number of "marks" for that
  couple. I'd like a result which lists the number of couples which have <code>x</code> marks
  or more for each of the values of <code>x</code>. So my input looks like:</p>
  
  <pre>
  | couple_id | num_marks |
  |-----------+-----------|
  |         9 |         7 |
  |         6 |         6 |
  |         8 |         6 |
  |         2 |         5 |
  |         3 |         4 |
  |         5 |         4 |
  |         1 |         3 |
  |         4 |         3 |
  |        10 |         2 |
  |         7 |         1 |
  </pre>
  
  <p>And I'd like to get the result:</p>
  
  <pre>
  | num_marks | num_couples |
  |-----------+-------------|
  |         7 | 1           |
  |         6 | 3           |
  |         5 | 4           |
  |         4 | 6           |
  |         3 | 8           |
  |         2 | 9           |
  |         1 | 10          |
  </pre>
  
  <p>I.e. there was 1 couple with 7 or more marks, 3 couples with 6 or more marks, 4
  couples with 5 or more marks, etc. I've been able to come up with a query to
  return the number of couples with <em>exactly</em> <code>n</code> marks:</p>
  
  <pre><code>SELECT num_marks,
         count(couple_id) AS num_couples
    FROM table_name
    GROUP BY num_marks
    ORDER BY num_marks DESC;
  </code></pre>
  
  <p>Which yields:</p>
  
  <pre>
  | num_marks | num_couples |
  |-----------+-------------|
  |         7 |           1 |
  |         6 |           2 |
  |         5 |           1 |
  |         4 |           2 |
  |         3 |           2 |
  |         2 |           1 |
  |         1 |           1 |
  </pre>
  
  <p>I.e. there was 1 couple with 7 marks, 2 couples with 6 marks, 1 with 5, etc. Is
  there a convenient way effectively to sum the value of each row with those above
  it? I can do it at the application level, but it seems like the kind of thing
  which really belongs in the database.</p>