title: How to split a column into multiple columns ordered by date
body: <p>I'm having a lot of problems when trying to get the data of my database in a proper format.
  I'm looking for the way to print the output of my database in columns by days.</p>
  
  <p>My database has two columns, one with a <code>timestamp</code> in a format like <code>YYYY-MM-DD H:M</code> and another colum with data related to a speed.</p>
  
  <p>I need to split the speed data in columns by day.</p>
  
  <p>More or less, my database is something like this (with 288 data everyday):</p>
  
  <pre><code> Timestamp          |   Speed
  
  2014-05-01 00:03:00 |   328.71    
  2014-05-01 00:18:00 |   331.31    
  2014-05-01 00:33:00 |   193.83        
  2014-05-02 00:03:00 |   321.21    
  2014-05-02 00:18:00 |   290.39    
  2014-05-02 00:33:00 |   283.43
  </code></pre>
  
  <p>And what I'm looking for is:</p>
  
  <pre><code>Hour    | 2014-05-01 | 2014-05-02
  
  00:03:00 | 328.71    | 321.21     
  00:18:00 | 331.31    | 290.39    
  00:33:00 | 193.83    | 283.43
  </code></pre>
  
  <p>First of all, I've tried to do in a static way, but when I get it, I'll do dynamic.</p>
  
  <p>The query I've made is</p>
  
  <pre><code>SELECT 
  (CASE WHEN Timestamp&gt;='2014-05-01' AND Timestamp&lt;='2014-05-03' 
      THEN date_format(Timestamp,'%H:%i') ELSE 0 END) AS 'Hour', 
  (CASE WHEN Timestamp&gt;='2014-05-01' AND Timestamp&lt;='2014-05-02' 
      THEN speed ELSE 0 END) AS '2014-05-01', 
  (CASE WHEN Timestamp&gt;='2014-05-02' AND Timestamp&lt;='2014-05-03' 
      THEN velocidad ELSE 0 END) AS '2014-05-02' 
  FROM `db_speed` 
  WHERE Timestamp&gt;='2014-05-01' AND Timestamp&lt;='2014-05-10
  </code></pre>
  
  <p>With this query, I get a structure like this:</p>
  
  <pre><code>Hour     | 2014-05-01 | 2014-05-02
  
  00:03:00 | 328.71     | 0     
  00:18:00 | 331.31     | 0    
  00:33:00 | 193.83     | 0    
  00:03:00 | 0          | 321.21     
  00:18:00 | 0          | 290.39
  00:33:00 | 0          | 283.43
  </code></pre>