Subject | Re: [ib-support] Group by behavior |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2002-10-24T11:46:36Z |
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.
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
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 aNo, you cannot have comparison within the count, you would have to do
>count(d.Assessor_DT < a.AssesmentDate) and a
>count(d.PlannedAssessor <> a.Assessor)
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