title: MySQL DATETIME sort with virtual datetable
body: <p>I have a table with some events in conjunction with timestamp as DATETIME.
  Now I want to have a statistic about my data, e.g. how much events per day... In some cases I don´t have events every day and of course I don´t get in my statistic that days with no existens entries.</p>
  
  <pre><code>| id | DATE           | COUNT      |
  | 1  | 2014-09-06     | 1          |
  | 2  | 2014-09-07     | 8          |
  | 3  | 2014-09-10     | 2          |
  | 4  | 2014-09-14     | 78         |
  </code></pre>
  
  <p>So i wrote a little script who generates me a query to solv that problem. It generates a virtual table with my days i want to know and do a LEFT OUTER JOIN with my event table. 
  So i will got all dates without gaps! The query looks like this e.g.:</p>
  
  <pre><code>SELECT DATE_FORMAT(d.date, '%d.%m.%Y') as datum, COUNT(l.id) as anzahl 
  FROM
  ( 
  SELECT STR_TO_DATE('25.11.2014', '%d.%m.%Y') as date UNION ALL
  SELECT STR_TO_DATE('26.11.2014', '%d.%m.%Y') as date UNION ALL
  SELECT STR_TO_DATE('27.11.2014', '%d.%m.%Y') as date UNION ALL 
  SELECT STR_TO_DATE('28.11.2014', '%d.%m.%Y') as date UNION ALL 
  SELECT STR_TO_DATE('29.11.2014', '%d.%m.%Y') as date UNION ALL 
  SELECT STR_TO_DATE('30.11.2014', '%d.%m.%Y') as date UNION ALL 
  SELECT STR_TO_DATE('01.12.2014', '%d.%m.%Y') as date
  ) as d 
  LEFT OUTER JOIN events l ON d.date = DATE(l.date) 
  GROUP BY datum 
  ORDER BY datum DESC
  </code></pre>
  
  <p>This query works absolute perfectly and i have also dates with no data in my statistic.</p>
  
  <p>But now comes the real problem i have: the sorting doesn´t work! I got some weird output. I have no idea what the problem is. The output looks like this:</p>
  
  <pre><code>| DATE          | COUNT |
  | 31.10.2014    | 0     |
  | 30.11.2014    | 5     |
  | 30.10.2014    | 0     |
  | 29.11.2014    | 0     |
  | 29.10.2014    | 0     |
  | 28.11.2014    | 0     |
  | 28.10.2014    | 0     |
  | 27.11.2014    | 0     |
  | 27.10.2014    | 0     |
  | 26.11.2014    | 0     |
  | 26.10.2014    | 0     |
  | 25.11.2014    | 1     |
  | 25.10.2014    | 0     |
  | 24.11.2014    | 1     |
  | 24.10.2014    | 0     |
  | 23.11.2014    | 0     |
  | 23.10.2014    | 0     |
  | 22.11.2014    | 0     |
  | 22.10.2014    | 0     |
  | 21.11.2014    | 1     |
  | 21.10.2014    | 0     |
  | 20.11.2014    | 0     |
  | 20.10.2014    | 0     |
  | 19.11.2014    | 2     |
  | 19.10.2014    | 0     |
  | 18.11.2014    | 0     |
  | 18.10.2014    | 0     |
  | 17.11.2014    | 0     |
  | 17.10.2014    | 0     |
  | 16.11.2014    | 0     |
  </code></pre>
  
  <p>So what´s wrong with my query? I have conscious use the function STR_TO_DATE i got a "real" date format. Normaly the sorting should work with it, isn´t it?</p>