|    
			
				11/11/2004, 06:32
			
			
			  | 
  |   |  |  |  Fecha de Ingreso: septiembre-2004 
						Mensajes: 141
					 Antigüedad: 21 años, 1 mes Puntos: 0 |  | 
  |  mira cumpa mis tablas son temporales porque Atrasado en proceso no existen como tal solo existen en la tabla tipo_email que tiene  1 si es en proceso, 2 si es atrasado, y 3 si es cerrado
 mira te adjunto el sotre procedure qu me esta funcionando hasta el momento, ahora estoy pegado tratando de sacar un porcentaje
 
 cumpa tu podrias auyudarme a lograr qe funcione
 --------------------------------------------------------------
 --------------------------------------------------------------
 CREATE PROCEDURE SPX AS
 
 
 
 
 select  distinct tipo_email,tema2_email,0 as EnProceso,0 as Atrasado,0 as Cerrado,0 as CerradoAtrasado,count(*) as TOTAL
 into ##r1
 from profile
 group by tipo_email,tema2_email
 
 
 
 select
 count(*)as total ,p.tipo_email
 into ##r2
 from profile p
 where estado1=1
 group by p.tipo_email
 
 update ##r1  set Enproceso=r2.total
 from ##r1 r1, ##r2 r2
 where r1.tipo_email=r2.tipo_email
 
 
 
 
 drop table ##r2
 
 
 
 select
 count(*)    total ,p.tipo_email
 into ##r3
 from profile p
 where estado1=2
 group by p.tipo_email
 
 
 update ##r1  set Atrasado=r3.total
 from ##r1 r1, ##r3 r3
 where r1.tipo_email=r3.tipo_email
 
 
 
 drop table ##r3
 
 
 
 
 select
 count(*)    total ,p.tipo_email
 into ##r4
 from profile p
 where estado1=3
 group by p.tipo_email
 
 
 update ##r1  set Cerrado=r4.total
 from ##r1 r1, ##r4 r4
 where r1.tipo_email=r4.tipo_email
 
 drop table ##r4
 
 
 
 select
 count(*)    total ,p.tipo_email
 into ##r5
 from profile p
 where estado1=4
 group by p.tipo_email
 
 
 update ##r1  set CerradoAtrasado=r5.total
 from ##r1 r1, ##r5 r5
 where r1.tipo_email=r5.tipo_email
 
 select  * from ##r1
 drop table ##r5
 drop table ##r1
 GO
 
 -----------------------------------------------------------
     |