これは集計クエリです。ただし、必要な期間ごとに変数を取得し、最終的な計算を行うために日ごとに合計します。
select product,
sum(DailySum*IsToday) as Today,
sum(1.0*DailySum*IslastMonth) / sum(IslastMonth)
sum(1.0*DailySum*IsYTD) / sum(IsYTD)
from (select product, cast(dt as date) as thedate, sum(val) as DailySum
(case when cast(dt as date) = cast(getdate() as date) then 1 else 0 end) as IsToday,
(case when year(dt) = year(dateadd(month, -1, getdate()) and month(dt) = month(dateadd(month, -1, getdate())
then 1 else 0
end) as IslastMonth,
(case when year(dt) = year(getdate()) tehn 1 else 0
end) as IsYTD
from t
group by product, cast(dt as date)
) t
) t