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

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 24-05-2006
hmoner hmoner is offline
Miembro
 
Registrado: may 2005
Posts: 52
Poder: 20
hmoner Va por buen camino
Hola amigos nuevamente
Al final pude solucionar el problema, con la siguiente consulta:

Código:
SELECT CLIENTE.NROSOCIO AS SOCIO, CLIENTE.NOMBRE AS CLIENTE, CLIENTE.APELLIDO AS APELLIDO, CLIENTE.ESTABLECIMIENTO AS ESTABLECIMIENTO,
(select SUM(case when espromoesp=true then 0 else F.MONTO end)
from Facturacion as F
where F.idcliente = cliente.id) AS M_NORMAL,
(select SUM(case when espromoesp=true then F.MONTO else 0 end)
from facturacion as F
where F.idcliente = cliente.id) AS M_ESPECIAL,
(select SUM(FAC.MONTO)
from Facturacion as FAC
where FAC.idcliente=cliente.id) AS TOT_MONTO,
(select sum(facturacion.puntos)
from Facturacion
where idcliente=cliente.id) as totalpuntosganados, (SELECT SUM(B.TOTALPUNTOS)
FROM CANJE B WHERE B.IDCLIENTE = cliente.id) as totalpuntoscanjeados, (select sum(facturacion.puntos)
from Facturacion
where idcliente=cliente.id) - (SELECT SUM(B.TOTALPUNTOS)
FROM CANJE B WHERE B.IDCLIENTE = cliente.id) as puntos_actuales
FROM CLIENTE where cliente.idpromo = 10
ORDER BY CLIENTE.APELLIDO ASC, CLIENTE.ESTABLECIMIENTO ASC
Y ahora tengo una pequeñita duda...
Si deseo filtrar este informe por FECHAS, donde debo poner dicho filtro ?

NOTA: FACTURACION.FECHA es el campo a filtrar... y por lo que veran, la tabla facturacion se usa como en 4 o 5 secciones de esta consulta...

He probado poner el filtro en cada lugar donde se usa la tabla facturacion pero no he tenido exito, me sale todo en blanco (no da error la consulta)

Desde ya muchas gracias
Responder Con Cita
Respuesta



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


La franja horaria es GMT +2. Ahora son las 09:02:29.


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