Re: restricting similar rows - Mailing list pgsql-novice

From Ciprian Popovici
Subject Re: restricting similar rows
Date
Msg-id 15412280174.20020919133946@integrare.ro
Whole thread Raw
In response to restricting similar rows  (Ciprian Popovici <ciprian.popovici@integrare.ro>)
List pgsql-novice
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>


pgsql-novice by date:

Previous
From: Joel Rodrigues
Date:
Subject: Re: 7.2.2 java configure problem on Mac OS X 10.1.5
Next
From: Rory Campbell-Lange
Date:
Subject: Make an id field max(id)+1 rather than SERIAL