Subject Query and problem with nulls
Author Luigi Siciliano
Hallo,

  The following query works fine but returns *all nulls* if no rows
between :DaData and :AData

SELECT

  DEPOSITO_ID,
  RIPORTO,
  CARICO,
  SCARICO,
  RIPORTO + ESISTENZA AS ESISTENZA,
  IMPEGNATI,
  ORDINATI
FROM
(
 SELECT
   DT.DEPOSITO_ID,
   (SELECT
      SUM(DC2.CARICO - DC2.SCARICO)
    FROM
      DOC_CORPO DC2,
      DOC_TESTA DT2
    WHERE
      DC2.DOC_TESTA_ID = DT2.ID
      AND DC2.ARTICOLO_ID = :ID
      AND DT2.DATA < :DaData
   ) AS RIPORTO,
   SUM(DC.CARICO) as Carico,
   SUM(DC.SCARICO) as Scarico,
   SUM(DC.CARICO - DC.SCARICO) as ESISTENZA,
   SUM(DC.IMPEGNATI) as Impegnati,
   SUM(DC.ORDINATI) as Ordinati
 FROM
   DOC_CORPO DC, DOC_TESTA DT
 WHERE
   DC.DOC_TESTA_ID = DT.ID
   AND DC.ARTICOLO_ID = :ID
   AND DT.DATA >= :DaData
   AND DT.DATA <= :AData
 GROUP BY
   DT.DEPOSITO_ID
)

How I can modify it?

Thanks.

--

Luigi Siciliano
--------------------------