From: | Alain(dot)Tesio(at)sip(dot)fr |
---|---|
To: | Holger Klawitter <holger(at)klawitter(dot)de>, PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org> |
Subject: | Re: [GENERAL] How to do this in Postgres |
Date: | 1999-11-23 12:34:39 |
Message-ID: | C1256832.00449D7E.00@applications.sip.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Try this :
select *
from data
group by id1,id2
having prio=min(prio)
I'm not sure it works with Postgres, using Sybase this would
returns a lot of duplicates since the group by mechanism is
a bit strange.
If it does't, this should work :
select id1,id2
into bogus
from data
group by id1,id2
having prio=min(prio)
select data.id1,data.id2,<<lots of data>>
from data,bogus
where data.id1=bogus.id1 and data.id2=bogus.id2
drop table bogus
Alain
--- Holger Klawitter <holger(at)klawitter(dot)de> wrote:
> Hi there,
>
> I tried all I could think of with the following problem, perhaps
> someone has another idea.
>
> I have a table where for each id there may (and often are) multiple
> rows with some kind of priority.
> create table data ( id1 int4, id2 int4, <<lots of data>>, prio
> int4 );
> The minimal priority is not guaranteed to be 1. There are 200k
> different ids with up to 10 entries, summing up to 400k rows.
>
> Not I want to do something like this:
>
> select * from data where <<prio is minimal per id pair>>.
From | Date | Subject | |
---|---|---|---|
Next Message | Fabian.Frederick | 1999-11-23 14:12:10 | RE: [GENERAL] How to do this in Postgres |
Previous Message | Jochen Topf | 1999-11-23 12:10:25 | Re: Is PostgreSQL ready for mission critical applications? |