Join in Oracle SQL -


is possible achieve below mentioned output table 1 , table 2 have tried joins outer join,left join,right join required output not achieved output.please me .

this can achieved using partition outer join:

with table1 (select 2014 yr, 'main' division, 2000 amt dual union                 select 2015 yr, 'main' division, 6000 amt dual union                 select 2016 yr, 'main' division, 7000 amt dual),      table2 (select 2014 yr, 'center' division, 100 amt dual union                 select 2015 yr, 'center' division, 200 amt dual union                 select 2016 yr, 'center' division, 350 amt dual), -- end of mimicking tables; wouldn't need above -- have tables. -- need following subquery define years you're querying -- against, though. can define either in clause -- or inline view in main sql below       years (select 2014 yr dual union                 select 2015 yr dual union                 select 2016 yr dual union                 select 2017 yr dual) select yrs.yr,        t.division,        nvl(t.amt, 0) amt   years yrs        left outer join (select yr, division, amt table1                         union                         select yr, division, amt table2) t partition (t.division)           on yrs.yr = t.yr order t.division, yrs.yr;          yr division        amt ---------- -------- ----------       2014 center          100       2015 center          200       2016 center          350       2017 center            0       2014 main           2000       2015 main           6000       2016 main           7000       2017 main              0 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -