Count total rows by year in MySQL
Question:How to count total rows by year in MySQL?
SELECT YEAR(publish_date) as publishYear, COUNT(*) AS totalRows FROM article GROUP BY YEAR(publish_date);
If you need to create a report where data is to be represented by year, you can use the built-in
YEAR() function in the
GROUP BY clause.
YEAR function returns the year for date, in the range 1000 to 9999, or 0 for the “zero” date.
Share "How to count total rows by year in MySQL?"
Tags:count by year, group by year, total by year, year, group, date, mysql
Technical term:Count total rows by year in MySQL