select
sum(case when e.Authority = 'TT' then e.Quantity else 0 end) as et_tt,
sum(case when e.Authority = 'OH' and isnull(e.d_t, '2040-1-1') <> t.LastTT then e.Quantity else 0 end) as et_oh,
sum(case when e.Authority = 'HO' and isnull(e.d_t, '2040-1-1') <> t.LastTT then e.Quantity else 0 end) as et_ho,
sum(case when e.Authority = 'SS' and isnull(e.d_t, '2040-1-1') <> t.LastTT then e.Quantity else 0 end) as et_ss
from dbo.Table1 e with (nolock)