Re: [SQL] CREATE INDEX with order clause

2006-02-03 Thread Ragnar
On Wed, 2006-02-01 at 10:46 -0500, Daniel Caune wrote: > Hi, > [snip need for reverse-sort operator class] > > SELECT GAME_CLIENT_VERSION > FROM GSLOG_EVENT > WHERE PLAYER_USERNAME = ? > AND EVENT_NAME = ? > AND EVENT_DATE_CREATED < ? > ORDER BY EVENT_DATE_CREATED DESC > LIMIT

[SQL] Help writing a piece of SQL

2006-02-03 Thread Nigel Bishop
Hi, I would appreciate some help writing a piece of SQL   PG803   My table/data looks like this:   username |    domain     |    sendto    +-+---+--  Postmaster   | intthit0

Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Richard Huxton
Nigel Bishop wrote: username |domain |sendto +-+---+- - Postmaster | intthit08.uk.rabbit.com | root root | intthit08.uk.rabbit.com | [EMAIL PROTECTED] stoat.grif

Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Nigel Bishop
Thanks for that Richard, it's almost what I'm after: So where the un and dm exist then return 1 row Where the un doestn't exist and dm does then return all sendtos' where the dm exists not just where the un='*' I hope that makes sense. Thanks for you help Nigel Bishop ioko T: +44 (0)1904 4

Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Niklas Johansson
On 3 feb 2006, at 11.43, Nigel Bishop wrote: The query will have the username and domain passed in as variables. If the username and domain exist then return the sendto The bit I’m struggling with is if the username doesn’t exist then return the sendto where the domain exists e.g. username=

Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Nigel Bishop
Niklas, Thank you very much, that did the business Cheers Nigel Bishop -Original Message- From: Niklas Johansson [mailto:[EMAIL PROTECTED] Sent: 03 February 2006 13:00 To: Nigel Bishop Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Help writing a piece of SQL On 3 feb 2006, at 11.43

Re: [SQL] Help writing a piece of SQL

2006-02-03 Thread Niklas Johansson
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