Subject | Re: [firebird-support] Help with query - Invalid expression in the select list |
---|---|
Author | Miroslav Penchev |
Post date | 2004-09-06T07:02:09Z |
Hi,
On Mon, 06 Sep 2004 10:02:17 +1000, Helen Borrie <helebor@...>
wrote:
SELECT
c.categoryid,
MAX(c.name) AS C_NAME, /*I will not use 'name' as field name - it is
quite dangerous*/
COUNT(x.categoryid)
FROM
categories c
LEFT JOIN books_to_categories x
ON c.categoryid = x.categoryid
GROUP BY c.categoryid
I am not sure which version of SELECT is more fast.
--
Miroslav Penchev
On Mon, 06 Sep 2004 10:02:17 +1000, Helen Borrie <helebor@...>
wrote:
> Just include all of the grouping columns in the column list:Or this one:
> SELECT
> c.categoryid,
> c.name,
> COUNT(x.categoryid)
> FROM
> categories c
> LEFT JOIN books_to_categories x
> ON c.categoryid = x.categoryid
> GROUP BY c.categoryid, c.name
>
SELECT
c.categoryid,
MAX(c.name) AS C_NAME, /*I will not use 'name' as field name - it is
quite dangerous*/
COUNT(x.categoryid)
FROM
categories c
LEFT JOIN books_to_categories x
ON c.categoryid = x.categoryid
GROUP BY c.categoryid
I am not sure which version of SELECT is more fast.
--
Miroslav Penchev