title: SQL query that will return multiple averages
body: <p>I'm trying to write a mysql query that will return an array of averages.
  I'll explain:</p>
  
  <p><img src="https://i.stack.imgur.com/HkOTT.png" alt="My rating table"></p>
  
  <p>As you can see from the picture, I have a web page that has a table with questions as rows, and usernames as columns. The idea is that you can rate each user on each question.
  When submitted, it goes into a mysql table "ratings" and each record holds the user id, question id and the value (rating of 1 through 10).
  What I want to do is, I want to have an admin view that, instead of being able to rate user, instead of each select box, it should simply display the average for each user, for each question.</p>
  
  <p>I could've done it in php by simply doing a mysql query for each cell in this table, but that would mean a gazillion queries.
  What I want, is one query that will return me a 2 dimensional array, where the first dimension key is the user ID, and the second dimension is the array with the averages themselves, with the key as question ID.</p>
  
  <p>I can't even begin to think of how to accomplish it. A solution, or even a hint on what direction to look at, will be most definitely appreciated!</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `ratings` (
    `rating_id` int(255) NOT NULL AUTO_INCREMENT,
    `user_id` int(6) NOT NULL,
    `question_id` int(6) NOT NULL,
    `rating_value` int(2) NOT NULL,
    PRIMARY KEY (`rating_id`),
    KEY `user_id` (`user_id`,`question_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
  </code></pre>