Ver Mensaje Individual
  #18 (permalink)  
Antiguo 07/09/2004, 15:02
Atzeneta
 
Fecha de Ingreso: junio-2004
Ubicación: Castellón, España
Mensajes: 98
Antigüedad: 19 años, 10 meses
Puntos: 0
Un poco rápido, mira a ver si te funciona:

SELECT cns.Fecha, cns_2.Suma_intereses_Depositos, cns_2.[Nº_documentos_depositos], cns_3.Suma_intereses_Devengados,
cns_3.[Nº_docs_devengados]
FROM (SELECT Fecha FROM (SELECT Fecha
FROM Operaciones UNION SELECT Fecha_deposito AS Fecha FROM Depositos) ncs_0
GROUP BY Fecha) cns LEFT OUTER JOIN
(SELECT Fecha_deposito, SUM(Interes) AS Suma_intereses_Depositos, COUNT(Interes) AS Nº_documentos_depositos
FROM Depositos
GROUP BY Fecha_deposito) cns_2 ON cns.Fecha = cns_2.Fecha_deposito LEFT OUTER JOIN
(SELECT Fecha, SUM(Interes) AS Suma_intereses_Devengados, COUNT(Interes) AS Nº_docs_devengados
FROM Operaciones
WHERE Estado2 = 'cartera'
GROUP BY Fecha) cns_3 ON cns.Fecha = cns_3.Fecha
WHERE (cns.Fecha BETWEEN CONVERT(DATETIME, '01/08/04') AND CONVERT(DATETIME, '01/08/04'))