Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > SQL
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #3  
Antiguo 01-04-2006
FOURIER FOURIER is offline
Miembro
 
Registrado: dic 2005
Posts: 40
Poder: 0
FOURIER Va por buen camino
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
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Primera consulta, mas lenta que el caballo del malo papulo Conexión con bases de datos 20 23-09-2005 13:46:24
Problamas consulta SQL gabsanar Firebird e Interbase 2 07-02-2005 09:33:05
Consulta muy lenta Walterdf Conexión con bases de datos 2 25-08-2004 18:37:57
Urgente!!! Problema con Consulta SQL PaLaSaca SQL 2 06-05-2004 19:56:50
lenta la consulta. digital Conexión con bases de datos 2 10-09-2003 15:38:13


La franja horaria es GMT +2. Ahora son las 00:18:15.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi