title: Count median grouped by day
body: <p>I have a script which counts median value for all table data:</p>
  
  <pre><code>SELECT avg(t1.price) as median_val FROM (
  SELECT @rownum:=@rownum+1 as `row_number`, d.price
    FROM mediana d,  (SELECT @rownum:=0) r
    WHERE 1
    ORDER BY d.price
  ) as t1, 
  (
    SELECT count(*) as total_rows
    FROM mediana d
    WHERE 1
  ) as t2
  AND t1.row_number&gt;=total_rows/2 and t1.row_number&lt;=total_rows/2+1;
  </code></pre>
  
  <p>Now I need to get median value not for all table values, but grouped by date. Is it possible? <a href="http://sqlfiddle.com/#!2/7cf27" rel="nofollow noreferrer">http://sqlfiddle.com/#!2/7cf27</a> - so as result I will get 2013-03-06 - 1.5 , 2013-03-05 - 3.5. </p>