Re: Table Join

From: ddf <oratune_at_msn.com>
Date: Tue, 14 Apr 2009 10:10:53 -0700 (PDT)
Message-ID: <e24b564c-4bf4-4016-a91e-aec5e4be2dc1_at_v28g2000vbb.googlegroups.com>



On Apr 14, 11:50 am, John Schaeffer <ame..._at_iwc.net> wrote:
> Hi, I'm hoping that there is a slick way to do this.
>
> I have 2 tables (below).  They both have the same structure except for
> the first column.  Is there a way to compare the tables and get the
> differences from TABLE A that are not in TABLE B, without having to
> use WHERE...AND...AND...AND for every column??
>
> TABLE A
> --------------
>  TICKER
>  CATEGORY_NAME
>  TOTAL_RETURN_1YR
>  TOTAL_RETURN_6MO
>  TOTAL_RETURN_3MO
>  TOTAL_RETURN
>  PERFORMANCE_RANK
>  ORDINAL_1YR
>  ORDINAL_6MO
>  ORDINAL_3MO
>  ORDINAL_RANK
>
> TABLE B
> --------------
>  TIME
>  TICKER
>  CATEGORY_NAME
>  TOTAL_RETURN_1YR
>  TOTAL_RETURN_6MO
>  TOTAL_RETURN_3MO
>  TOTAL_RETURN
>  PERFORMANCE_RANK
>  ORDINAL_1YR
>  ORDINAL_6MO
>  ORDINAL_3MO
>  ORDINAL_RANK
You COULD try this:

select
TICKER,
CATEGORY_NAME,

TOTAL_RETURN_1YR,
TOTAL_RETURN_6MO,
TOTAL_RETURN_3MO,
TOTAL_RETURN,

PERFORMANCE_RANK,
ORDINAL_1YR,
ORDINAL_6MO,
ORDINAL_3MO,
ORDINAL_RANK

from tablea
minus
select
TICKER,
CATEGORY_NAME,
TOTAL_RETURN_1YR,
TOTAL_RETURN_6MO,
TOTAL_RETURN_3MO,
TOTAL_RETURN,

PERFORMANCE_RANK,
ORDINAL_1YR,
ORDINAL_6MO,
ORDINAL_3MO,
ORDINAL_RANK

from tableb;

Searching the newsgroup would have found similar solutions.

David Fitzjarrell Received on Tue Apr 14 2009 - 12:10:53 CDT

Original text of this message