Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    3

    Unanswered: 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.

  2. #2
    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

  3. #3
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    3
    Thanks, I'll look into Unions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •