• You're good with what you're using UNION for, but you have to keep in mind that UNION vs. UNION ALL is the equivalent of using a DISTINCT or not on the query. It's not grouping/aggregating.

    So, for starters, you want to use UNION ALL there because you might otherwise be losing data that you need to feed into your aggregation, unless you can straight dupe rows between the two queries.

    Next, what you'll want to do is aggregate the union. It'll basically look like this:

    SELECT

    SiteCode,

    SUM( SomeStuff) AS SumOfStuff

    FROM

    (SELECT SiteCode, SomeStuff FROM table1

    UNION ALL

    SELECT SiteCode, SomeStuff From Table2

    ) AS drv

    GROUP By

    SiteCode


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA