title: ORDER BY and GROUP BY of MySQL query
body: <p>I have two mySQL tables as follows:</p>
  
  <pre><code>[product] table
  P_id | Name | Quantity
  1    | B    | 10
  2    | C    | 15
  3    | A    | 8
  
  [attribute] table 
  P_id | Name  | Quantity
  1    | Black | 5
  1    | Red   | 5
  2    | Blue  | 6
  2    | Black | 9
  </code></pre>
  
  <p>How can I write an SQL query so that it can show the result from the above two tables as follows:
  Report:</p>
  
  <pre><code>P_id | Name  | Quantity
  3    | A     | 8
  1    | B     | 10
  1    | Black | 5
  1    | Red   | 5
  2    | C     | 15
  2    | Black | 9
  2    | Blue  | 6
  </code></pre>
  
  <p>These should be sorted on [Name] column, but these should be grouping on P_id column as above. By "grouping" on P_id, I mean "keeping all records with the same P_id next to each other". IS it possible to retrieve as above arrangement using a single SQL query.</p>