HOLAS TENGO EL SIGUIENTE PROBLEMA QUIERO HACER ESTE PROCENTAJE PERO NO ME ESTA RESULTANDO
declare @Total1 int
declare @Cien float
select @Total1 = sum(TOTAL), @Cien=100.0 from ##r1
--select @total1 from ##r1
select tipo_email ,total, @total1 AS TOTAL2,
(@TOTAL1/total) AS DIVIDE,
(TOTAL/@TOTAL1) AS DIVIDE2
---(( convert (float, count(*) ) / @Total1 )*100.0 ) as totalP
--convert(float,(@totalX) as Porcentaje
from ##r1
group by tipo_email,total
--( convert (decimal(8,2), count(*))/' + convert(varchar,@Total) + ')*100) as Porcentaje %
order by tipo_email
Y ME DA
tipo_email total TOTAL2 DIVIDE DIVIDE2
-------------------------------------------------- ----------- ----------- ----------- -----------
1 4 11 2 0
2 3 11 3 0
3 1 11 11 0
4 3 11 3 0
(4 row(s) affected)