Thursday, September 19, 2002, 12:01:46 PM, Ciprian Popovici <ciprian.popovici@integrare.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.popovici@integrare.ro>