Re: Table Join

From: John Schaeffer <amerar_at_iwc.net>
Date: Tue, 14 Apr 2009 10:24:13 -0700 (PDT)
Message-ID: <eac590cc-e255-4ab7-a06b-bcc241877824_at_r33g2000yqn.googlegroups.com>



On Apr 14, 12:10 pm, ddf <orat..._at_msn.com> wrote:
> 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

I know, was just hoping to avoid all the column listings.....thought someone came up with a cool solution...... Received on Tue Apr 14 2009 - 12:24:13 CDT

Original text of this message