If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL, Two views into one

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-18-04, 15:04
zemp zemp is offline
Registered User
 
Join Date: Feb 2003
Location: Canada
Posts: 3
SQL, Two views into one

I have two views in SQL server that work great in summarizing data from two separate groups of tables in my database.

View1 has fields ID, RInv, RAmount, RDate, RAmtPaid
View2 has fields ID, CInv, CAmount, CDate, CAmtPaid

The correspondinmg fields are of the same data type and are linked by the ID fields.

What I would like is to get all of the records into a new view for a single ID value in the following format,

View3 has fields ID, Invoice, Amount, Date, AmtPaid

For example if View1 has 2 records for ID=10 and View2 has 1 records for ID=10 then view3 should have 3 records for ID=10.

First of all is this possible, secondly if so, how can I get it done.
Reply With Quote
  #2 (permalink)  
Old 02-18-04, 16:57
chuzhoi chuzhoi is offline
Registered User
 
Join Date: Dec 2002
Posts: 134
Re: SQL, Two views into one

If I understand your problem correctly, simple "union all" should help

create view ....
select ID, RInv, RAmount, RDate, RAmtPaid from View1
union all
select ID, CInv, CAmount, CDate, CAmtPaid from View2

-dmitri
Reply With Quote
  #3 (permalink)  
Old 02-18-04, 17:02
zemp zemp is offline
Registered User
 
Join Date: Feb 2003
Location: Canada
Posts: 3
Thanks, I'll look into Unions.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On