Re: Need some magic with alternative rows - Mailing list pgsql-sql

From Niklas Johansson
Subject Re: Need some magic with alternative rows
Date
Msg-id 99DA5C8C-F1D5-42BC-8416-5B91C72269D0@tele2.se
Whole thread Raw
In response to Need some magic with alternative rows  (Andreas <maps.on@gmx.net>)
List pgsql-sql
On 7 jun 2008, at 05.04, Andreas wrote:
> Is there a way to remove the default-rows if there exists a fk<>0  
> row that has the same group_nr ?

Yes, use a correlated sub-query:

SELECT * FROM mytab m1
WHERE fk = 994010 OR (class_nr = 40 AND fk = 0 AND NOT EXISTS (SELECT  
1 FROM mytab m2 WHERE m2.group_nr=m1.group_nr AND fk <> 0));




Sincerely,

Niklas Johansson





pgsql-sql by date:

Previous
From: Andreas
Date:
Subject: Need some magic with alternative rows
Next
From: Andrei
Date:
Subject: Parallel updates on multiple cores