with t1 as (
select cast('20240101 00:00:00' as datetime) as fdate,56 as fnum
union all
select cast('20241231 00:00:00' as datetime) as fdate,36 as fnum
union all
select cast('20240221 00:00:00' as datetime) as fdate,68 as fnum
union all
select cast('20240518 00:00:00' as datetime) as fdate,19 as fnum
union all
select cast('20240815 00:00:00' as datetime) as fdate,82 as fnum
union all
select cast('20240423 00:00:00' as datetime) as fdate,73 as fnum)
select
--当年最后一天零点
sum(case when fdate=dateadd(year,datediff(year,0,dateadd(year,1,getdate())),-1) and fnum is not null then fnum else 0 end) -
--当年第一天零点
sum(case when fdate=dateadd(yy,datediff(yy,0,getdate()),0) and fnum is not null then fnum else 0 end) as fcz
from t1