Subject Re: [ib-support] Group by behavior
Author Arno Brinkman
Hi,


> Hi
> I have the following query
>
> select
> d.Darno,
> d.PlannedAssessor,
> a.Assessor,
> d.Assessor_DT,
> a.AssesmentDate
> from DAR d inner join ACCIDENTCLAIMPROCESS a on d.darno=a.darno
>
> order by d.plannedassessor
>
> I want the query to group by d.plannedassesor but I get a invalid column
> reference error. I have looked at the examples in the Embedded SQL Guide
> but I can't see any difference between how group by is used there and
> how I use it.( I suspect I dont fully understand the functioning of
> group by yet)
>
> What I also want to do with the group by is have a count on
> d.plannedassesor.
>
> Would it be possible to have something like a
> count(d.Assessor_DT < a.AssesmentDate) and a
> count(d.PlannedAssessor <> a.Assessor)

GROUP BY does what it said ;-) It groups data by the columns you specify and
on the other data you can do calculations such as SUM,AVG,COUNT,MIN and MAX.


With this "count(d.Assessor_DT < a.AssesmentDate)" maybe you meant this :

SELECT
Count(*)
FROM
DAR d
JOIN ACCIDENTCLAIMPROCESS a on d.darno=a.darno
WHERE
d.PlannedAssessor <> a.Assessor
GROUP BY
d.PlannedAssessor

Regards,
Arno