select count(顶层码), 年份, 大类 from 表 group by 年份,大类
select 年份,大类,count(distinct 顶层码)
from 表
group by 年份,大类