Index: /branches/2.1/include/dblayer/functions_pdo-sqlite.inc.php
===================================================================
--- /branches/2.1/include/dblayer/functions_pdo-sqlite.inc.php	(revision 6342)
+++ /branches/2.1/include/dblayer/functions_pdo-sqlite.inc.php	(revision 6464)
@@ -47,4 +47,5 @@
 
   $link->sqliteCreateFunction('now', 'pwg_now', 0);
+  $link->sqliteCreateFunction('hour', 'pwg_hour', 1);
   $link->sqliteCreateFunction('unix_timestamp', 'pwg_unix_timestamp', 0);
   $link->sqliteCreateFunction('md5', 'md5', 1);
@@ -571,4 +572,9 @@
 }
 
+function pwg_hour($datetime)
+{
+  return strftime('%H', $datetime);
+}
+
 function pwg_unix_timestamp()
 {
Index: /branches/2.1/include/dblayer/functions_sqlite.inc.php
===================================================================
--- /branches/2.1/include/dblayer/functions_sqlite.inc.php	(revision 6342)
+++ /branches/2.1/include/dblayer/functions_sqlite.inc.php	(revision 6464)
@@ -56,4 +56,5 @@
 
   $link->createFunction('now', 'pwg_now', 0);
+  $link->createFunction('hour', 'pwg_hour', 1);
   $link->createFunction('unix_timestamp', 'pwg_unix_timestamp', 0);
   $link->createFunction('md5', 'md5', 1);
@@ -583,4 +584,9 @@
 }
 
+function pwg_hour($datetime)
+{
+  return strftime('%H', $datetime);
+}
+
 function pwg_unix_timestamp()
 {
Index: /branches/2.1/admin/stats.php
===================================================================
--- /branches/2.1/admin/stats.php	(revision 6364)
+++ /branches/2.1/admin/stats.php	(revision 6464)
@@ -117,5 +117,5 @@
 SELECT
     date,
-    HOUR(time) AS hour,
+    hour(time) AS hour,
     MAX(id) AS max_id,
     COUNT(*) AS nb_pages
@@ -123,6 +123,9 @@
   WHERE summarized = \'false\'
   GROUP BY
+    date,
+    hour
+  ORDER BY
     date ASC,
-    HOUR(time) ASC
+    hour ASC
 ;';
 $result = pwg_query($query);
