From: | Ken Hill <ken(at)scottshill(dot)com> |
---|---|
To: | Bricklen Anderson <banderson(at)presinet(dot)com> |
Cc: | pgsql(at)yukonho(dot)de, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Syntax for "IF" clause in SELECT |
Date: | 2006-02-09 02:06:10 |
Message-ID: | 1139450771.15713.5.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
This has been something I've been trying do so that I can do some column
comparisons as part of "data-cleaning" work. I'll let you know if this
helps me accomplish my task!
On Wed, 2006-02-08 at 15:20 -0800, Bricklen Anderson wrote:
> pgsql(at)yukonho(dot)de wrote:
> > Greetings,
> >
> > the following is an MySQL statement that I would like to
> > translate to PostgreSQL:
> >
> > Could someone point me to a documentation of a coresponding
> > Systax for an "IF" clause in the a SELECT,
> > or is the some other way to do this....
> >
> > select
> > if(spektrum is null,' ','J'),
> > if(s19 is null,' ','J'),
> > if(OhneGrenze is null,' ','J'),
> > from namen;
> >
> >
> > Do I need to create my own function to allow this behaviour!
> >
> >
> > my best regards,
> >
> > Stefan
>
> use CASE
>
> Since I'm not a user of MySQL, and if I'm reading your query correctly:
> try
> select (CASE when spektrum is null then 'J' else spektrum end),
> ...
>
> or if you are just trying to replace nulls, then try COALESCE
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | Ken Hill | 2006-02-09 02:34:22 | Re: unique constraint instead of primary key? what |
Previous Message | george young | 2006-02-09 02:04:55 | unique constraint instead of primary key? what disadvantage(ODBC usage)? |