On Thu, 1 Apr 2004, John Liu wrote: > 1. In the database allowing 'illegal distinct/w orderby not in the target > list' > select distinct drugname, drugid, encdate from CCMMed where pnum_site > ='1913789_MC' order by drugname, encdate, mshdatetime desc; > > 2. In Pg, use your query group by then order by - > select drugname, drugid, encdate from ccmmed where pnum_site ='1913789_MC' > group by drugname, drugid, encdate order by max(mshdatetime); This should be order by drugname, encdate, max(mshdatetime) to be equivalent to the above I would think. ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org