This is my query:
select locid,tlid,locdescription from ( select locid, tlid, locdescription from trip_log left join trip_log_det on tlid=tldtripid left join locations on tldlocation=locid where tlid=50 order by tldid ) as foo group by locid,tlid,locdescription
The point of using a subquery is to get data back ordered as per the internal query, so sorted by
tldid. I do not need
tldid in the data as it is a serial column and it would nullify the
group by statement.
Is there a way to tell the subquery to maintain the ordering of the internal query?