Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 2nd, 2008, 12:58 PM
Newbie
 
Join Date: Sep 2008
Posts: 1
Default Join two identically structured views

Hi

I have two views that contain the same columns of the same types. They also have the same amount of rows with the same primary keys.

E.g.
Code:
VIEW_A
ID	VALUE
1	(null)
2	1001
3	(null)

VIEW_B
ID	VALUE
1	81007941
2	(null)
3	(null)
I would like to create a third view VIEW_COMBO that combines the two views, getting as many values as possible. I.e. getting the value 81007941 from VIEW_B and the value 1001 from VIEW_A and (null) for the third row where no value exists.

E.g.
Code:
VIEW_COMBO
ID	VALUE
1	81007941
2	1001
3	(null)
Is this possible somehow to write a sql query that does that?

Best regards,
Mattias
Reply
  #2  
Old September 2nd, 2008, 04:30 PM
docdiesel's Avatar
Moderator
 
Join Date: Aug 2007
Location: Munich
Posts: 279
Default

Hi,

if the destination would be a table, then it could be realised with a MERGE statement. But by the way - what about a PK=4 with VALUE=123 in View_A and VALUE=456 in View_B? Which value should show up in the target table/view ?

Regards,

Bernd
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles