Re: select distinct w/order by

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: John Liu <johnl(at)emrx(dot)com>
Cc: "'scott(dot)marlowe'" <scott(dot)marlowe(at)ihs(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: select distinct w/order by
Date: 2004-04-01 16:35:04
Message-ID: 20040401083342.W936@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message wespvp 2004-04-01 16:53:40 Compound keys and foreign constraints
Previous Message Nick Barr 2004-04-01 16:29:29 Re: Select Union