[vox-tech] SQL help - unions
David Hummel
dhml at comcast.net
Tue Jul 20 18:44:26 PDT 2004
On Tue, Jul 20, 2004 at 06:20:06PM -0700, Jeff Newmiller wrote:
>
> The existence of separate tables with identical structures and disjoint
> data in your schema is a red flag to me.
>
> I highly recommend putting all the data into one table with a "Season"
> column to distinguish the rows... it simplifies these kinds of queries and
> makes the data much more useful for mining.
To be proper about it, you would normalize this by putting the season
and year in respective separate tables, and place foreign keys to these
in the SSN table. But it doesn't sound like this schema needs to be
overly complex. Separate tables does simplify archiving etc., and
whatever works.
> As the other respondents suggested, different SQL engines have different
> levels of support for the language.
>
> SELECT SSN from [Fall 2003] WHERE race == 1
> UNION
> SELECT SSN from [Spring 2004] WHERE race == 1
The comparison operator for equal is '=' not '=='.
> gets you a little bit closer, but there are a couple of problems with
> this... it isn't really obtaining a headcount,
Yes it is. As is Michael Wenk's version.
> and unions don't eliminate duplicates.
Yes they do.
-David
More information about the vox-tech
mailing list