I think this can help you.I changed to this and tested it was right
declare @Responded int
declare @Total int
declare @Participated int
set @Total=(select SUM([count]) as Total from [dbo].[tb1])
set @Participated=(select SUM([count]) as Participated from [dbo].[tb1]
where Status in('allowed', 'to_be_paid', 'already_paid'))
set @Responded=( select SUM([count]) as Responded from [dbo].[tb1]
where Status in('allowed', 'to_be_paid', 'already_paid', 'user_declined', 'user_willing'))
(SELECT [Status]
,cast([count] as DECIMAL(38,0))
FROM [Identity].[dbo].[tb1]
)
union
(
select 'Total',cast(@Total as DECIMAL(38,0))
)
union
(
select 'Participated',cast(@Participated as DECIMAL(38,0))
)
union
(
select 'Responded',cast(@Responded as DECIMAL(38,0))
)
union
(
select 'No response',cast(SUM([count]) as DECIMAL(38,0)) as [count] from [dbo].[tb1]
where Status in('expired', 'offered')
)
union(
select 'Response rate', cast(((100.0 * @Responded)/ @Total)as DECIMAL(38,0)) as [count]
)
union(
select 'Participation rate',cast(((100.0 * @Participated)/ @Total)as DECIMAL(38,0))as [count]
)
