The first SELECT works but I want to filter it with a subquery. NOw
instead I have a VIEW but it is really slow. I want to try a
subquery but I don't know how to relate the two queries. The 2nd query
I want as a subquery not a VIEW. The relationship would be [car_mark
AND car_number] but I don't know if I need a HAVING or an IN or
another join since it is an aggregate in the 2nd query?? Or do I need
to start all over?
tia,
SELECT c.l_e , c.car_mark , c.car_number , c.location_city ,
c.location_state ,
c.sighting_date , e.classification , c.railroad , s.city as
origin_city ,
s.state as origin_state , c.destination_city , c.destination_state ,
t.eta
FROM INTERNAL_REMARK r, INTERNAL_CAR_LEASE cl,
INTERNAL_CODES e, INTERNAL_CLM c
LEFT JOIN (
INTERNAL_TRIPS t, INTERNAL_SPLC s)
ON ( c.trip_id = t.trip_id
AND t.origin_splc_id = s.splc_id )
WHERE cl.lease_id = "74"
AND cl.remark_id = r.remark_id
AND r.car_mark = c.car_mark
------
(select INTERNAL_CLM.car_mark AS car_mark,
INTERNAL_CLM.car_number AS car_number,
max(INTERNAL_CLM.sighting_date)
AS sighting_date from INTERNAL_CLM
group by INTERNAL_CLM.car_mark,INTERNAL_CLM.car_number
John Bell - 29 Jun 2008 18:22 GMT
> The first SELECT works but I want to filter it with a subquery. NOw
> instead I have a VIEW but it is really slow. I want to try a
[quoted text clipped - 28 lines]
> AS sighting_date from INTERNAL_CLM
> group by INTERNAL_CLM.car_mark,INTERNAL_CLM.car_number
See my reply to your other post http://tinyurl.com/6kgv5e
John