- Instant help with your Sql coding problems

Count total rows by year in MySQL

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.

The YEAR function returns the year for date, in the range 1000 to 9999, or 0 for the “zero” date.

YEAR reference
Share "How to count total rows by year in MySQL?"