Hi there, I need your help.
I tried this query but I need other type of output.
Can you help me?
thank you
Correct output:
My query:Code:+------+--------+ | year | number | +------+--------+ | 2001 | 2987 | | 2003 | 364 | | 2004 | 400 | | 2005 | 217 | | 2006 | 135 | | 2007 | 143 | | 2008 | 225 | | 2009 | 261 | | 2010 | 393 | | 2011 | 363 | | 2012 | 253 | | 2013 | 1 | | tot_ | 5542 | +------+--------+
Code:mysql> SELECT CASE WHEN YEAR (myDate) IS NULL OR YEAR (myDate) = '2001' THEN '2001' ELSE YEAR (myDate) END AS year, COUNT(*) AS number FROM tbl_login GROUP BY YEAR (myDate); +------+--------+ | year | number | +------+--------+ | 2001 | 2986 | | 2001 | 1 | | 2003 | 364 | | 2004 | 400 | | 2005 | 217 | | 2006 | 135 | | 2007 | 143 | | 2008 | 225 | | 2009 | 261 | | 2010 | 393 | | 2011 | 363 | | 2012 | 253 | | 2013 | 1 | +------+--------+ 13 rows in set



Reply With Quote






Bookmarks