Ver Mensaje Individual
  #2  
Antiguo 01-04-2006
FOURIER FOURIER is offline
Miembro
 
Registrado: dic 2005
Posts: 40
Reputación: 0
FOURIER Va por buen camino
Hola

Pues Yo Probaria
Código Delphi [-]
Select First 20 F.claveart,a.desart,a.marca,a.grupo,  Coalesce(sum(f.cantidad),0)-  (select Coalesce(sum(cantidad),0) From 
Tinv_invmovim   Where (tipomov='dm' Or Tipomov='dx') And   Claveart = F.claveart And   Fechamov Between '01.01.2006' And 
'24.03.2006') cantidad,  Coalesce(sum(f.impsiva),0)-  ((select Coalesce(sum(importe),0) From Tinv_invmovim    Where 
(tipomov='dm' Or Tipomov='dx') And    Claveart = F.claveart And    Fechamov Between '01.01.2006' And '24.03.2006')+   (select 
Case When Coalesce(sum(c.impartnc),0)>0 Then Coalesce(sum(c.impartnc),0)   Else 0 End From Tcxc_climovim C    Right Join 
Tfac_facturas Ff On (ff.tipomov = Substring(c.factura From 1 For 2) And Ff.foliofiscal= Cast(substring(c.factura From 3 For 6) As 
Integer))    Right Join Tfac_dfacturas Fd On (fd.tipomov = Ff.tipomov And Fd.folio = Ff.folio And Fd.claveart=f.claveart)    Where 
(tipomov='nm' Or Tipomov='nx') And    Fechamov Between '01.01.2006' And '24.03.2006')) total,   (select 
Coalesce(sum(impsiva),0) From Tfac_dfacturas    Where Claveart = F.claveart And Tipomov ='fm' And    Fechafac Between 
'01.01.2005' And '24.03.2005') -   ((select Coalesce(sum(importe),0) From Tinv_invmovim     Where (tipomov='dm' Or Tipomov='dx')
 And     Claveart = F.claveart And     Fechamov Between '01.01.2005' And '24.03.2005') +    (select Case When 
Coalesce(sum(c.impartnc),0)>0 Then Coalesce(sum(impartnc),0) Else 0 End From Tcxc_climovim C     Right Join Tfac_facturas Ff 
On (ff.tipomov = Substring(c.factura From 1 For 2) And Ff.foliofiscal = Cast(substring(c.factura From 3 For 6) As Integer))     Right
 Join Tfac_dfacturas Fd On (fd.tipomov = Ff.tipomov And Fd.folio = Ff.folio And Fd.claveart=f.claveart)     Where (tipomov='nm' Or 
Tipomov='nx') And     Fechamov Between '01.01.2005' And '24.03.2005')) totant,    (select Coalesce(sum(cantidad),0) From 
Tfac_dfacturas     Where Claveart = F.claveart And     Tipomov ='fm' And     Fechafac Between '01.01.2005' And '24.03.2005') -    
(select Coalesce(sum(cantidad),0) From Tinv_invmovim     Where (tipomov='dm' Or Tipomov='dx') And     Claveart = F.claveart And    
 Fechamov Between '01.01.2005' And '24.03.2005') cantantfrom Tfac_dfacturas Fjoin Tinv_articulos  A On (f.claveart = 
A.claveart)where F.fechafac Between '01.01.2006' And '24.03.2006' Andf.tipomov ='fm'group By 
F.claveart,a.desart,a.marca,a.grupoorder By   Coalesce(sum(f.cantidad),0)-  (select Coalesce(sum(cantidad),0) From 
Tinv_invmovim   Where (tipomov='dm' Or Tipomov='dx') And   Claveart = F.claveart And   Fechamov Between '01.01.2006' And 
'24.03.2006') cantidad,  Coalesce(sum(f.impsiva),0)-  ((select Coalesce(sum(importe),0) From Tinv_invmovim    Where 
(tipomov='dm' Or Tipomov='dx') And    Claveart = F.claveart And    Fechamov Between '01.01.2006' And '24.03.2006')+   (select 
Case When Coalesce(sum(c.impartnc),0)>0 Then Coalesce(sum(c.impartnc),0)   Else 0 End From Tcxc_climovim C    Right Join 
Tfac_facturas Ff On (ff.tipomov = Substring(c.factura From 1 For 2) And Ff.foliofiscal= Cast(substring(c.factura From 3 For 6) As 
Integer))    Right Join Tfac_dfacturas Fd On (fd.tipomov = Ff.tipomov And Fd.folio = Ff.folio And Fd.claveart=f.claveart)    Where 
(tipomov='nm' Or Tipomov='nx') And    Fechamov Between '01.01.2006' And '24.03.2006')) total,   (select 
Coalesce(sum(impsiva),0) From Tfac_dfacturas    Where Claveart = F.claveart And Tipomov ='fm' And    Fechafac Between 
'01.01.2005' And '24.03.2005') -   ((select Coalesce(sum(importe),0) From Tinv_invmovim     Where (tipomov='dm' Or Tipomov='dx')
 And     Claveart = F.claveart And     Fechamov Between '01.01.2005' And '24.03.2005') +    (select Case When 
Coalesce(sum(c.impartnc),0)>0 Then Coalesce(sum(impartnc),0) Else 0 End From Tcxc_climovim C     Right Join Tfac_facturas Ff 
On (ff.tipomov = Substring(c.factura From 1 For 2) And Ff.foliofiscal = Cast(substring(c.factura From 3 For 6) As Integer))     Right
 Join Tfac_dfacturas Fd On (fd.tipomov = Ff.tipomov And Fd.folio = Ff.folio And Fd.claveart=f.claveart)     Where (tipomov='nm' Or 
Tipomov='nx') And     Fechamov Between '01.01.2005' And '24.03.2005')) totant,    (select Coalesce(sum(cantidad),0) From 
Tfac_dfacturas     Where Claveart = F.claveart And     Tipomov ='fm' And     Fechafac Between '01.01.2005' And '24.03.2005') -    
(select Coalesce(sum(cantidad),0) From Tinv_invmovim     Where (tipomov='dm' Or Tipomov='dx') And     Claveart = F.claveart And    
 Fechamov Between '01.01.2005' And '24.03.2005') Desc

Última edición por marcoszorrilla fecha: 01-04-2006 a las 22:26:01.
Responder Con Cita