Skip site navigation (1) Skip section navigation (2)

Re: Need some magic with alternative rows

From: Niklas Johansson <spot(at)tele2(dot)se>
To: Andreas <maps(dot)on(at)gmx(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Need some magic with alternative rows
Date: 2008-06-08 09:59:22
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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));


Niklas Johansson

In response to

pgsql-sql by date

Next:From: AndreiDate: 2008-06-09 08:29:58
Subject: Parallel updates on multiple cores
Previous:From: AndreasDate: 2008-06-07 03:04:05
Subject: Need some magic with alternative rows

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group