Subject | Re: [ib-support] JOIN the mess |
---|---|
Author | Lucas Franzen |
Post date | 2003-03-24T19:15:53Z |
Scott,
Every column you have in select clause taht is NOT a statistic function
(SUM, COUNT, etc.) MUST have a corresponding entry in the group by
clause.
This is not an IB/FB restriction, this is just SQL syntax.
Change it to:
select d.trkid, t.LeaseOpID
from disp_leg d
join Truck_ID t on d.TrkID = t.TrkID
group by d.trkid, t.LeaseOpID
and it will work - but only give you an overview of all combinations of
this two fields.
Add "t.leaseopid" to yor SELECT __AND__ your GROUP BY.
Luc.
> select d.trkid, t.LeaseOpIDin general:
> from disp_leg d
> join Truck_ID t on d.TrkID = t.TrkID
> group by d.trkid
Every column you have in select clause taht is NOT a statistic function
(SUM, COUNT, etc.) MUST have a corresponding entry in the group by
clause.
This is not an IB/FB restriction, this is just SQL syntax.
Change it to:
select d.trkid, t.LeaseOpID
from disp_leg d
join Truck_ID t on d.TrkID = t.TrkID
group by d.trkid, t.LeaseOpID
and it will work - but only give you an overview of all combinations of
this two fields.
> Ultimately, this statement works well:see above.
> SELECT COUNT (*) numhauls, d.TrkID
> , SUM(h.cycletime) CycleTime
> FROM disp_leg d
> JOIN Truck_ID t on d.TrkID = t.TrkID
> JOIN Trk_Hauls h on d.HaulID = h.HaulID
> WHERE d.dumpdate >= '03/01/03'
> AND d.dumpdate <= '03/03/03'
> AND d.complete = 'Y'
> AND d.TrkID >= '1'
> AND d.TrkID <= '20'
> GROUP BY d.TrkID
>
> This gives me everything I need, except the t.leaseopid, when I add it to
> the list I get back to that error message again.
>
> Only slightly frustrating. Can anyone point out my obvious mistake?
Add "t.leaseopid" to yor SELECT __AND__ your GROUP BY.
Luc.