Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    2

    Question Unanswered: Create view based on two tables

    I'm trying to create a view based on the data I get from running both of these statements.

    (select distinct COLUMN1, COLUMN2, COLUMN3
    from TABLE1
    MINUS
    select COLUMN1, COLUMN2, COLUMN3
    from TABLE2)

    (select distinct COLUMN1, COLUMN2, COLUMN3
    from TABLE2
    MINUS
    select COLUMN1, COLUMN2, COLUMN3
    from TABLE1)

    The result I would like for the new table is
    Column1,Column2,Column3
    (data from both tables)

  2. #2
    Join Date
    Apr 2003
    Location
    NY
    Posts
    208
    Create Or Replace View NAME (
    COLUMN1 DataType,
    COLUMN2 DataType,
    COLUMN3 DataType)
    IS
    (select distinct COLUMN1, COLUMN2, COLUMN3
    from TABLE1
    MINUS
    select COLUMN1, COLUMN2, COLUMN3
    from TABLE2)
    UNION
    (select distinct COLUMN1, COLUMN2, COLUMN3
    from TABLE2
    MINUS
    select COLUMN1, COLUMN2, COLUMN3
    from TABLE1);

  3. #3
    Join Date
    Oct 2004
    Posts
    2

    Talking

    Thanks!!!!!!!!!!!

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    If the two queries do not have duplicates then use "UNION ALL". If it has duplications, then use "UNION". The UNION ALL is much faster then a UNION because it doesn't have to check for dups.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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