mysql select help

mysql select help

am 09.09.2006 20:21:48 von Kalvi

Hi!

What wrong on this clause?

SELECT * from summad SUM(sum1+sum2+sum3) AS summa HAVING summa > sumall

Tx for help

Re: mysql select help

am 09.09.2006 21:08:07 von IchBin

Mikro wrote:
> Hi!
>
> What wrong on this clause?
>
> SELECT * from summad SUM(sum1+sum2+sum3) AS summa HAVING summa > sumall
>
> Tx for help
>
>
Do not know your table layout but you can not have a 'SUM' after the
FROM clause and before the 'HAVING' clause. You use the 'SUM' in either
your 'SELECT' statement or the 'Having' clause. Also you can not have a
'HAVING' clause without a 'GROUP BY' clause.

Look here:
http://www.techonthenet.com/sql/having.php

--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

Re: mysql select help

am 11.09.2006 17:09:24 von nc

Mikro wrote:
>
> What wrong on this clause?
>
> SELECT * from summad SUM(sum1+sum2+sum3)
> AS summa HAVING summa > sumall

Everything. You list a data item to select (summa) after a FROM clause
(it should be before). You also combine retrieving records with
retrieving aggregates from the same table, which doesn't make sense.

Cheers,
NC