Ver Mensaje Individual
  #4  
Antiguo 18-03-2011
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.013
Reputación: 21
oscarac Va por buen camino
lo solucione de esta manera
aver si alguien tiene alguna idea mejor

Código SQL [-]
select M.Periodo, M.LIbro, M.Voucher, M.ANEXO Into #Prueba
from tblmovimientocontable M where M.AFC ='P' and 
M.Periodo = :Periodo1 and M.Libro = :Libro1
 
Select M.Periodo, M.Libro, M.Voucher, M.Documento, P.Anexo,
SUM(Case when M.AFC = 'V' then M.n_imp else 0 end ) As Valor,
SUM(Case when M.AFC = 'I' then M.n_imp else 0 end) As IGV,
SUM(Case when M.AFC = 'N' then M.n_imp else 0 end) As NoAfecto,
SUM(case when M.AFC = 'P' then M.n_imp else 0 end ) As Total
 from tblmovimientocontable M 
Left Join #prueba P on M.Periodo = P.Periodo and M.Libro = P.Libro and P.Voucher = M.Voucher
where M.Periodo = :Periodo and M.Libro = :Libro
group by M.Periodo, M.Libro, M.Voucher, M.documento, P.ANEXO
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita