mysql select help

Hi!

What wrong on this clause?

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

Tx for help
Kalvi [ Sa, 09 September 2006 20:21 ] [ ID #1460749 ]

Re: mysql select help

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-)
IchBin [ Sa, 09 September 2006 21:08 ] [ ID #1460750 ]

Re: mysql select help

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
nc [ Mo, 11 September 2006 17:09 ] [ ID #1462402 ]
PHP » alt.php.sql » mysql select help

Vorheriges Thema: [PEAR] How to get the value of an auto_increment primary key after an insert ?
Nächstes Thema: mysql dump creates empty file