Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

oracle full outer join problem

Posted on 2007-11-18
1
Medium Priority
?
2,809 Views
Last Modified: 2013-12-19
SQL> select * from test1;

STATE     ID            NAME                 PARAM         count1
---------- ---------- -------------------- ---------- ----------
AK         1234       testname1            bo                 1
AK         1235       testname2            bo                 1
MA         1234       testname1            ao                 1
AK         1234       testname1            ao                 2
MA         1235       testname5            ao                 3
testbo  is view created from table test1 for param bo
SQL> select * from testbo;
  
STATE      ID          NAME                 PARAM          count1
---------- ---------- -------------------- ---------- ----------
AK         1234       testname1            bo                 1
AK         1235       testname2            bo                 1
 
 
SQL> select * from testao; this is view for param ao
 
STATE      ID     NAME                 PARAM              count1
---------- ---------- -------------------- ---------- ----------
MA         1234       testname1            ao                 1
AK         1234       testname1            ao                 2
MA         1235       testname5            ao                 3
 
 
 
SQL> select a.state,a.id,a.name,a.count1 as bo,b.count1 as ao from
testbo a full outer join testao b on a.state =b.state and a.name =b.name and a.id = b.id
    
STATE      ID            NAME                        bo       ao
---------- ---------- -------------------- ---------- ----------
AK         1234       testname1                     1          2
AK         1235       testname2                     1
                                                               1
                                                               3
 
 
How to display state ,ID,name values for ao as it was displaying only count1.
 
Best Regards,

Open in new window

0
Comment
Question by:pk143143
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 20310471
you have to coalesce the fields:

SQL> select coalesce(a.state, b.state) state
  ,coalesce(a.id, b,id) id
 ,coalesce(a.name, b.name) name
,a.count1 as bo
,b.count1 as ao 
from testbo a 
full outer join testao b 
   on a.state =b.state 
  and a.name =b.name 
  and a.id = b.id
 ;

Open in new window

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question