title: SQL Query, Average climbed and pair that has climbed the most peaks
body: <p>My Databases look like so:</p>
  
  <ul>
  <li>PEAK (NAME, ELEV, DIFF, MAP, REGION)</li>
  <li>CLIMBER (NAME, SEX)</li>
  <li>PARTICIPATED (TRIP_ID, NAME) </li>
  <li>CLIMBED (TRIP_ID, PEAK, WHEN)</li>
  </ul>
  
  <p>PEAK gives info about the mountain peaks that the user is interested in. The table lists the name of each peak, it elevation(in ft), its difficulty level(on a scale of 1-5), the map that it is located on, and the region of the Sierra Nevada that it is located in.</p>
  
  <p>CLIMBER lists the members of club, and gives their name and gender.</p>
  
  <p>PARTICIPATED gives the set of climbers who participated in each of the various climbing trips. The number of participants in each trip varies.</p>
  
  <p>CLIMBED tells which peaks were climbed on each climbing trip, along w/ the data that each peak was climbed.</p>
  
  <p>I need help with writing a query for the following:</p>
  
  <ol>
  <li>Compute the average number of peaks scaled by the men in the club and by the women in the club. </li>
  <li>Which pair of climbers have climbed the most peaks together, and how many peaks is that?</li>
  <li>Who has climbed more than 20 peaks in some 60 day span?</li>
  </ol>
  
  <p>For the first query, so far I have found a way to compute the total number of peaks climbed by either gender, for men:</p>
  
  <pre><code>SELECT SUM(C)
  FROM 
    (SELECT CD.PEAK, COUNT(*) C
    FROM CLIMBED CD
    WHERE CD.TRIP_ID IN
      (SELECT TRIP_ID
      FROM PARTICIPATED PA
      WHERE PA.NAME IN 
        (SELECT NAME
        FROM CLIMBER
        WHERE SEX = 'M'))
    GROUP BY CD.PEAK) T;
  </code></pre>
  
  <p>For the second query, I have the following which I'm fairly sure isn't correct:</p>
  
  <pre><code>SELECT TEMP2.TRIP_ID, COUNT (*)
  FROM
    (SELECT P1.NAME, P2.NAME, P1.TRIP_ID
    FROM PARTICIPATED P1, PARTICIPATED P2
    WHERE P1.NAME &lt;&gt; P2.NAME AND
          P1.TRIP_ID = P2.TRIP_ID) TEMP1,
    (SELECT *
    FROM CLIMBED) TEMP2
  WHERE TEMP2.TRIP_ID = TEMP1.TRIP_ID
  GROUP BY TEMP2.TRIP_ID;
  </code></pre>