Subject | Re: [ib-support] GROUP BY and JOINS - How to? |
---|---|
Author | Arno Brinkman |
Post date | 2003-05-17T19:24:59Z |
Hi,
clause or ORDER BY clause must be an part of the GROUP BY clause or an
aggregate-function. Thus add the necessary fields to the GROUP BY clause :
SELECT
products.idproduct,
products.name,
SUM(batchs.stockl)
FROM
products LEFT JOIN batchs ON batchs.idproduct=product.idproduct
GROUP BY
products.idproduct,
products.name
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird links :
http://www.firebirdsql.com
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Nederlandse firebird nieuwsgroep :
news://80.126.130.81
See you at the First European Firebird Conference May 19-20 in Fulda,
Germany
http://www.firebird-conference.com
> I was trying to "translate" a very complex query and I got an error, so Ione...
> simplified the error an I get this query to be the simpler erroneous
>error
> When doing something like this I get an error message...
>
> SELECT
> products.idproduct,
> products.name,
> SUM(batchs.stockl)
> FROM
> products LEFT JOIN batchs ON batchs.idproduct=product.idproduct
> GROUP BY products.idproduct
>
> When I run this select I get a "Invalid token. Dynamic SQL Error. SQL
> code = -104. invalid column reference.".If you have an aggregate-query every column inside the select_list, HAVING
clause or ORDER BY clause must be an part of the GROUP BY clause or an
aggregate-function. Thus add the necessary fields to the GROUP BY clause :
SELECT
products.idproduct,
products.name,
SUM(batchs.stockl)
FROM
products LEFT JOIN batchs ON batchs.idproduct=product.idproduct
GROUP BY
products.idproduct,
products.name
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird links :
http://www.firebirdsql.com
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Nederlandse firebird nieuwsgroep :
news://80.126.130.81
See you at the First European Firebird Conference May 19-20 in Fulda,
Germany
http://www.firebird-conference.com