Ver Mensaje Individual
  #13  
Antiguo 24-05-2006
hmoner hmoner is offline
Miembro
 
Registrado: may 2005
Posts: 52
Reputación: 19
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