Subject | How merge two queries |
---|---|
Author | Luigi Siciliano |
Post date | 2014-09-10T16:01:41Z |
Hallo,
I have two queries:
First (results: ANNO, IMPONIBILE):
select
EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) AS ANNO,
SUM(DC.IMPORTO) AS IMPONIBILE
from
DOC_CORPO DC,
DOC_TESTA DT,
VOCI V
WHERE
DT.ID = DOC_TESTA_ID
AND DT.DOCUMENTO_ID <> 'PRO'
AND EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) = 2013
AND DC.VOCE_ID = V.ID
AND V.CONTRIBUTI = 1
GROUP BY EXTRACT(YEAR FROM DT.DATA_DOCUMENTO)
Second (results: ANNO, IMPOSTA):
select
EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) AS ANNO,
SUM(DC.IMPORTO) AS IMPOSTA
from
DOC_CORPO DC,
DOC_TESTA DT
WHERE
DT.ID = DOC_TESTA_ID
AND DT.DOCUMENTO_ID <> 'PRO'
AND EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) = 2013
AND DC.VOCE_ID = 'ENPACL'
GROUP BY EXTRACT(YEAR FROM DT.DATA_DOCUMENTO)
There is a way to merge those two queries to obtain the same result in
one query that results: ANNO, IMPONIBILE, IMPOSTA?
Thanks.
--
Luigi Siciliano
--------------------------
I have two queries:
First (results: ANNO, IMPONIBILE):
select
EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) AS ANNO,
SUM(DC.IMPORTO) AS IMPONIBILE
from
DOC_CORPO DC,
DOC_TESTA DT,
VOCI V
WHERE
DT.ID = DOC_TESTA_ID
AND DT.DOCUMENTO_ID <> 'PRO'
AND EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) = 2013
AND DC.VOCE_ID = V.ID
AND V.CONTRIBUTI = 1
GROUP BY EXTRACT(YEAR FROM DT.DATA_DOCUMENTO)
Second (results: ANNO, IMPOSTA):
select
EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) AS ANNO,
SUM(DC.IMPORTO) AS IMPOSTA
from
DOC_CORPO DC,
DOC_TESTA DT
WHERE
DT.ID = DOC_TESTA_ID
AND DT.DOCUMENTO_ID <> 'PRO'
AND EXTRACT(YEAR FROM DT.DATA_DOCUMENTO) = 2013
AND DC.VOCE_ID = 'ENPACL'
GROUP BY EXTRACT(YEAR FROM DT.DATA_DOCUMENTO)
There is a way to merge those two queries to obtain the same result in
one query that results: ANNO, IMPONIBILE, IMPOSTA?
Thanks.
--
Luigi Siciliano
--------------------------