insert into temporary table in sql server


DECLARE @result1 TABLE(subtype VARCHAR(5), total INT)

INSERT INTO @result1(subtype, total)
select DISTINCT top 2 t.subtype, t.total
from [test] t, [person] p
where (t.[record] = 'fc2765f2-ca90-48c2-a705-d2526c92d56d')
and p.[id] = t.[record]
and (t.[type] = 'SATII')
/*and (t.[rank_confirmed_subtype] = 1)*/
and (confirmed != 0 or confirmed IS NULL)
order by t.[total] desc

select total from @result1