select y, COUNT(*) from (select (select DATEPART(year, time)) as y, * from warning_info) newtable where time <= ( select max(time) from warning_info) and time>=(select min(time) from warning_info) and status = 70 group by newtable.y
思路:先取出表数据的年份,然后再创建新的表,最后分组统计