pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Niklas Johansson <spot@tele2.se>
To: Nigel Bishop <Nigel.Bishop@ioko.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Help writing a piece of SQL
Date: Fri, 3 Feb 2006 14:20:31 +0100
Message-ID: <3F3A99C3-2368-4DD2-9396-2A2C23B14CF1@tele2.se> (raw)
In-Reply-To: <72558D9A7573814BB4082A28843E03D402658B4E@intyodc01.uk.ioko365.com>
References: <72558D9A7573814BB4082A28843E03D402658B4E@intyodc01.uk.ioko365.com>


On 3 feb 2006, at 14.06, Nigel Bishop wrote:

> Thank you very much, that did the business


This should generate the same plan as the previous query, but be a  
little bit more clean and easy to read:

SELECT sendto FROM users t1
WHERE domain='rusty.com' AND
username = COALESCE((SELECT username FROM users WHERE username='fred'  
and domain=t1.domain), username);



Sincerely,

Niklas Johansson






view thread (6+ messages)

Message-ID: <3F3A99C3-2368-4DD2-9396-2A2C23B14CF1@tele2.se>
Permalink:  ../3F3A99C3-2368-4DD2-9396-2A2C23B14CF1@tele2.se/
Also on:    postgresql.org/message-id/3F3A99C3-2368-4DD2-9396-2A2C23B14CF1@tele2.se

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: spot@tele2.se, Nigel.Bishop@ioko.com
  Subject: Re: Help writing a piece of SQL
  In-Reply-To: <3F3A99C3-2368-4DD2-9396-2A2C23B14CF1@tele2.se>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox