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
--------------------------



------------------------------------

------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/firebird-support/join
    (Yahoo! ID required)

<*> To change settings via email:
    firebird-support-dig...@yahoogroups.com 
    firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
    https://info.yahoo.com/legal/us/yahoo/utos/terms/

  • [firebird-suppor... Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
    • Re: [firebi... Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
      • Re: [fi... Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
        • Re:... Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
          • ... Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
            • ... Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
          • ... Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
    • [firebird-s... Rustam rusta...@ukr.net [firebird-support]
      • Re: [fi... Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
        • Re:... Luigi Siciliano luigi...@tiscalinet.it [firebird-support]
        • Re:... setysvar setys...@gmail.com [firebird-support]

Reply via email to