我有以下的输出:MySQL的计数在一个请求几个表
[email protected] [~]# mysql -e "SELECT TABLE_ROWS from information_schema.Tables where TABLE_SCHEMA= 'testdb' && TABLE_NAME = 'requests';"
+------------+
| TABLE_ROWS |
+------------+
| 9566846 |
+------------+
[email protected] [~]# mysql -e "select count(*) from testdb.requests where created_at like '2012%';"
+----------+
| count(*) |
+----------+
| 301438 |
+----------+
[email protected] [~]# mysql -e "select count(*) from testdb.requests where created_at like '2013%';"
+----------+
| count(*) |
+----------+
| 24917 |
+----------+
如何会更好,使用MySQL的要求做同样的一个请求,让新的输出像
+------------------+-----------------------+
| year | count(*) |
+------------------+-----------------------+
| 2009 | 1066268 |
| 2010 | 6799553 |
| 2011 | 1374685 |
| 2012 | 301438 |
| 2013 | 24917 |
| total | 9566846 |
+------------------+-----------------------+
谢谢你在前进,Evgheni
非常感谢 – 2013-02-12 08:27:35
非常欢迎。快乐的编码。 – peterm 2013-02-12 08:28:11