computations when doing a join

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Josh

    #1

    computations when doing a join

    I have two tables with the same structure and need to compare the
    similar rows where they exist. That's the easy part. However, I can't
    figure out a way to do a calculation when a specific row only exists
    in one of the tables.

    Ex:
    Table A
    --------------
    | id | value |
    --------------
    | 1 | 10 |
    | 2 | 20 |
    --------------

    Table B
    --------------
    | id | value |
    --------------
    | 2 | 25 |
    | 3 | 35 |
    --------------

    I'd like the result to reflect the sum of the values
    --------------
    | id | value |
    --------------
    | 1 | 10 |
    | 2 | 45 |
    | 3 | 65 |
    --------------

    But what I get when doing a join is
    --------------
    | id | value |
    --------------
    | 1 | 10 |
    | 2 | null |
    | 3 | null |
    --------------

    I feel like the process should be simple but haven't had any luck
    using Joins or Unions to do this. Any ideas? Thanks in advance
Working...