首页 > 代码库 > 10.4 补充范围内丢失的值

10.4 补充范围内丢失的值

select y.yr.coalesce(x.cnt,0) as cnt
from (
select min_year-mod(cast(min_year as int),10)+rn as yr
from (
select (select min(extract(year from hreadate))
from emp) as min_year,
id-1 as rn
from t10
) a
) y
left join
(
select extract(year from hredate) as yr,count(*) as cnt
from emp
group by extract(year from hiredate)
) x
on (y.yr=x.yr);

10.4 补充范围内丢失的值