Ver Mensaje Individual
  #11  
Antiguo 14-12-2005
hmoner hmoner is offline
Miembro
 
Registrado: may 2005
Posts: 52
Reputación: 19
hmoner Va por buen camino
Bueno bueno...
Faltan palabras de agradecimiento para FOURIER, quien tan amablemente se ha ofrecido a ayudarme con mi problema, a traves del MSN Messenger, y se ha quedado hasta que finalmente pude hacer funcionar y unificar la consulta.
Hoy, he tenido muchisima suerte... gracias FOURIER.
Aqui la consulta terminada, por si a alguien le sirve...

Compatible con NEXUS ( motor de base de datos 3rdparty para Delphi - www.nexusdb.com )

Código SQL [-]
 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 = :PIDPROMO
 ORDER BY CLIENTE.APELLIDO ASC, CLIENTE.ESTABLECIMIENTO ASC
Responder Con Cita