From: | Ciprian Popovici <ciprian(dot)popovici(at)integrare(dot)ro> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: restricting similar rows |
Date: | 2002-09-19 10:39:46 |
Message-ID: | 15412280174.20020919133946@integrare.ro |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Thursday, September 19, 2002, 12:01:46 PM, Ciprian Popovici <ciprian(dot)popovici(at)integrare(dot)ro> wrote:
> need all of them. Plus I don't know how to properly translate this
> query into Postgres.
Figured it out, eventually. Here's the Postgres query:
select distinct on (code) \
id,code,active from objects \
where version<=1 and (process=17 or process=0) \
group by id,code,active,version \
order by code asc,active desc,version desc
I supply version and process values and I get whatever I need back
(id,code,active). Kudos to Postgres for the 'distinct on' clause.
-- Ciprian Popovici <ciprian(dot)popovici(at)integrare(dot)ro>
From | Date | Subject | |
---|---|---|---|
Next Message | Rory Campbell-Lange | 2002-09-19 14:14:17 | Make an id field max(id)+1 rather than SERIAL |
Previous Message | Joel Rodrigues | 2002-09-19 09:43:39 | Re: 7.2.2 java configure problem on Mac OS X 10.1.5 |