mysql - Counting data based on decades -


i have table books column release year of book (type: year). want count number of books released in every decade.

i have tried following:

select count(*) count, concat(decade, '-', decade + 9) releaseyear (     select floor('releaseyear' / 10) * 10 decade     book ) t group decade; 

but returns 0 results.

when try year('releaseyear') returns nulls.

create decade value each row , find count(decade) .. group decade.

query

select t.decade,count(t.decade) bookscount (     select *,     concat((releaseyear - ((releaseyear % 10)-1)),'-',((releaseyear - ((releaseyear % 10)-1))+ 9)) decade    books )t group t.decade; 

sql fiddle


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -