mysql - SQL: How to sum up count for many decades? -
i learning sql queries , have question below
"a decade sequence of ten consecutive years, e.g. 1982, 1983... 1991. each decade, compute total number of publications in dblp in decade."
i have come temporary table count of each year select count(id) cnt, year publication group year
so next step sum cnt year decade. after research, found use between operator. however, still need specify range 1 one. there better way this? (the year range 1900 - 2015)
thank much.
after research, find group , left() can lot.
select left(year, 3) decade , sum(cnt) (select count(id) cnt, year publication group year) t1 group left(year, 3) ;
the result
decade cnt
null 6 193 55 194 139 195 1066 196 8066 197 28449 198 93203 199 359628 200 1249767 201 947365
do please give suggestions if there better ways it. thank you.
Comments
Post a Comment