title: SQL command to group field and create new column
body: <p>I have a table: <code>name, date, url, no</code>, <code>url</code> includes <code>"facebook","twitter","other"</code>.</p>
  
  <p>How can I generate a new table: <code>date, facebook, twitter, total, unique name</code>, such that, grouping by date, <code>facebook</code> field is the sum of the <code>no</code> WHERE <code>url="facebook"</code>, and same as <code>twitter</code>; <code>total</code> field is the sum of the <code>no</code> of all; <code>unique name</code> counts the distinct <code>name</code> number?</p>