Subject Re: [ib-support] Group by behavior
Author Svein Erling Tysvaer
Hi Gerhardus,

when using GROUP BY you must group by all fields not aggregate, i.e.

SELECT A, count(distinct B)
FROM MyTable
GROUP BY A

is legal, whereas

SELECT A, C, count(distinct B)
FROM MyTable
GROUP BY A

is illegal, since C is neither aggregate nor in the GROUP BY.

>Would it be possible to have something like a
>count(d.Assessor_DT < a.AssesmentDate) and a
>count(d.PlannedAssessor <> a.Assessor)

No, you cannot have comparison within the count, you would have to do
something like

select
d.Darno,
d.PlannedAssessor,
a.Assessor,
count(*)
from DAR d inner join ACCIDENTCLAIMPROCESS a on d.darno=a.darno
where (d.Assessor_DT < a.AssesmentDate)
GROUP BY d.Darno, d.PlannedAssessor, a.Assessor,

Hope this answers your questions, even though I didn't quite understand
what you meant,
Set