Subject | Re: [firebird-support] query per year |
---|---|
Author | Helen Borrie |
Post date | 2004-12-08T20:40:59Z |
At 05:21 PM 8/12/2004 +0100, you wrote:
BY clause. Do this:
SELECT
PersId,
Extract (YEAR FROM EncDate) as EncYear,
Count(Id)
FROM Encounter
GROUP BY 1, 2
ORDER BY 1, 2
./hb
>Hi all,You can't refer to a derived field (EncYear) by name in a GROUP BY or ORDER
>
>I want to make a query it which I count for each person the number of
>encounters for each year.
>So I want something like:
>SELECT PersId, Extract (YEAR FROM EncDate) as EncYear, Count(Id) FROM
>Encounter
> GROUP BY PersId, EncYear ODER BY PersId, EncYear.
>
>This is not correct. What is wrong?
BY clause. Do this:
SELECT
PersId,
Extract (YEAR FROM EncDate) as EncYear,
Count(Id)
FROM Encounter
GROUP BY 1, 2
ORDER BY 1, 2
./hb