Oracle: one query to output different where condition result -
i've got following query output plots 3 rows , 3 columns. each "owner" want extract on same line "pdf" in common , "pdf" doesn't exist on second table.
do know other elegant , faster way show in same query output result of different conditions?
with temp (select t.owner, (select flh_punto_erogazione dual exists (select 1 netatemp.backlog_nobill_storico p p.flh_punto_erogazione = t.flh_punto_erogazione)) "pdf in comune", (select flh_punto_erogazione dual not exists (select 1 netatemp.backlog_nobill_storico p p.flh_punto_erogazione = t.flh_punto_erogazione)) "pdf non in comune" netatemp.tmp_backlog_nobilling2013_uff t) select owner, count (distinct "pdf in comune") "pdf in comune", count (distinct "pdf non in comune") "pdf non in comune" temp group owner
i used external join, hoped understood need:
select owner, sum(common) "pdf in comune", count(*) - sum(common) "pdf non in comune" ( select t.owner, p.flh_punto_erogazione, decode(t.flh_punto_erogazione, null, 0, 1) common netatemp.tmp_backlog_nobilling2013_uff t, netatemp.backlog_nobill_storico p p.flh_punto_erogazione (+) = t.flh_punto_erogazione ) group owner
Comments
Post a Comment