title: how to find teams with sql command
body: <p>I'm writing a program for a running contest using SQLite database, and I have to determine teams from the finish data. There are schools taking part of the contest, and one team consist of four(exactly four) people from one school. A school can have more than one team. The team position is determined by the sum of the members positions. The contestants are stored in one table with their finish position name and school. </p>
  
  <p>Can it be done by SQL query or should I solve it in code?</p>
  
  <pre><code>Example:
  pos     name    school            pos    name     school
  1      person1   foo               1     person1   foo
  2      person2   foo               2     person2   foo
  3      person3   bar               6     person6   foo
  4      person4   bar               8     person8   foo
  5      person5   bar     -&gt;        3     person3   bar
  6      person6   foo               4     person4   bar
  7      person7   bar               5     person5   bar
  8      person8   foo               7     person7   bar
  9      person9   foo
  10     person10  foo
  11     person11  bar
  </code></pre>