Keith,
Thanks for the reply. I think the HAVING is okay. I simplified it incorrectly. Here is the actual GROUP and HAVING clauses:
GROUP BY
RetailDate
, StoreNo
, Category
HAVING
SUM(RegUnits) <> 0
OR SUM(RegRetail) <> 0
OR SUM(RegCost) <> 0
OR SUM(ClrUnits) <> 0
OR SUM(ClrRetail) <> 0
OR SUM(ClrCost) <> 0
I can post (or send directly to you) the entire query if you think it would help.
Chad
>Chad,
>
>I think that the HAVING clause is throwing the query out of whack. It looks like the aggregate functions are missing in the clause. If the clause was changed to the aggregates instead of the source columns, the optimizer would be forced to use the GROUP BY on the outer query.
_________________________________
There are 2 types of people in the world: