473,465 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Join two identically structured views

1 New Member
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.
Expand|Select|Wrap|Line Numbers
  1. VIEW_A
  2. ID    VALUE
  3. 1    (null)
  4. 2    1001
  5. 3    (null)
  6.  
  7. VIEW_B
  8. ID    VALUE
  9. 1    81007941
  10. 2    (null)
  11. 3    (null)
  12.  
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.
Expand|Select|Wrap|Line Numbers
  1. VIEW_COMBO
  2. ID    VALUE
  3. 1    81007941
  4. 2    1001
  5. 3    (null)
  6.  
Is this possible somehow to write a sql query that does that?

Best regards,
Mattias
Sep 2 '08 #1
1 1495
docdiesel
297 Recognized Expert Contributor
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
Sep 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Greg Stark | last post by:
I find I often want to be able to do joins against views where the view are aggregates on a column that has an index. Ie, something like SELECT a.*, v.n FROM a JOIN (select a_id,count(*) as n...
4
by: Andrei Ivanov | last post by:
Hello, I have 2 tables: CREATE TABLE products ( id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL ); CREATE TABLE products_daily_compacted_views ( product ...
3
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
2
by: Doug Crowson | last post by:
I have some questions about co-located joins and db partitions. I've heard various things from various people and was looking for confirmation. Assume the following tables and partitioning keys:...
3
by: rjaw | last post by:
Hi there, we have a problem using the left outer join-operation on a db2 database, v7, running on z/os. Defined are two tables, table1 and table2. Both tables have a primary key of field1,...
4
by: nekiv90 | last post by:
Greetings, I was able to create the structured type: CREATE TYPE address_t AS ( street char(30), city char(15), state char(10), postcode smallint ) MODE...
0
by: Dot Net Daddy | last post by:
Hi, I am new to MS-SQL and I have a problem. Actually I have made similar queries on Oracle, but now I failed on MS Sql. First of all I am using SQL Server 2005, but I think it is not that much...
21
patjones
by: patjones | last post by:
Hi all: My newest project involves creating a small help desk database for our customer service division to use. What will happen is that an employee will call up, explain his/her issue, and...
10
by: drweb | last post by:
i have made 2 views and concted them and my query is working find, but i want to make a 1 stored procedure from these 2 views ... View 1 SELECT dbo.page_information.page_id FROM ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.