Casey C Cook wrote:
> I have never been able to reference a name I have assigned to a column in
> the where clause.

WHERE runs before aggregation, HAVING runs after aggregation.


> Also, In an SQL book I have it says "The use of a
> HAVING clause without a corresponding GROUP BY clause is almost never seen
> in practice". (LAN TIMES Guide to SQL)

It is not common, but that doesn't make it illegal.


> I would agree with J E VanOver with the following:
>
> SELECT count(tony) as tonysCount, sum(jayme) as jaymesCount from orders
> WHERE Abs((count(tony)-sum(jayme))/count(tony)) > 0

That should work and is the only allowed way in SQL-92. However,
as off SQL:1999 using the assigned name in the HAVING is
permitted (but not widely supported).

Jochem


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to