Results 1 to 3 of 3

Thread: Outer Joins

  1. #1
    Join Date
    Jan 2004
    Posts
    67

    Unanswered: Outer Joins

    I have 2 Tables.

    Table A and Table B.

    Table A has a column called ID and there are 14 Records in the Table.
    Table B has 3 Columns columns called TID(Unique to Table B) and ID(Referring Table A) and Percentages

    Now all i want is a Single Query, that can retrieve me all the 14 Records
    and the corresponding Percentage from Table B , if they Exist.

    it should be something like this

    IDValue Percebtages
    ------------------------------------
    ID1 0
    ID2 0
    ID3 0
    ID4 5
    ID5 9
    ID6 0
    .
    .
    .
    .
    ID14 0

    this output means that table B has entries only for ID4 and ID5.

    Can anyone help me out in this

    Thanks
    Shankar

  2. #2
    Join Date
    Feb 2004
    Posts
    11

    Re: Outer Joins

    Originally posted by shankar
    I have 2 Tables.

    Table A and Table B.

    Table A has a column called ID and there are 14 Records in the Table.
    Table B has 3 Columns columns called TID(Unique to Table B) and ID(Referring Table A) and Percentages

    Now all i want is a Single Query, that can retrieve me all the 14 Records
    and the corresponding Percentage from Table B , if they Exist.

    it should be something like this

    IDValue Percebtages
    ------------------------------------
    ID1 0
    ID2 0
    ID3 0
    ID4 5
    ID5 9
    ID6 0
    .
    .
    .
    .
    ID14 0

    this output means that table B has entries only for ID4 and ID5.

    Can anyone help me out in this

    Thanks
    Shankar
    Hi ..

    the query goes like this

    select A.id,nvl(B.value,0),nvl(b.percenatge,0) from A,B
    where A.id = B.id(+)

    thanks
    jeethu
    learning Oracle

  3. #3
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Select ta.id, NVL(tb.percentage, 0)
    from tableA ta
    LEFT OUTER JOIN
    tableB tb ON
    ta.id = tb.id;
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Posting Permissions

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