pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Torbjörn Andersson <tobbe@embryo.se>
To: Kancha . <kancha2np@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: replace NULL
Date: Wed, 10 Apr 2002 13:42:05 +0200
Message-ID: <B8D9F1AD.22F5%tobbe@embryo.se> (raw)
In-Reply-To: <005501c1e076$f9f60fe0$5ce8fea9@GMENDOLA2>

Hi,
 
>> if age is NULL then I want to replace it by some text,
>> say "SHY" so the output is like
>> 
>> name age
>> me   10
>> jane SHY
>> jack 32

If you want to change the presentation but not the actual data you can use:

SELECT name, CASE 
    WHEN age IS NULL
    THEN 'SHY' 
    ELSE age 
    END AS age
FROM people


I think there is a function called coalesce (sp?) that does roughly the same
as the CASE-clause above.



Best Regards

Torbjörn "Toby" Andersson
---------------------------------------------------
Embryo Communication      phone: +46 (0) 31-774 39 11(00)
Kungsgatan 7a             fax: +46 (0)31 774 07 80
S-411 19 Gothenburg         mobile: 0708-30 70 04
Sweden                    home: http://www.embryo.se/
        mail: torbjorn.andersson@embryo.se
---------------------------------------------------
"A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts,
build a wall, set a bone, comfort the dying, take orders, give orders,
cooperate, act alone, solve equations, analyze a new problem, pitch manure,
program a computer, cook a tasty meal, fight efficiently, die gallantly.
Specialization is for insects"




view thread (4+ messages)

Message-ID: <B8D9F1AD.22F5%tobbe@embryo.se>
Permalink:  ../B8D9F1AD.22F5%25tobbe@embryo.se/
Also on:    postgresql.org/message-id/B8D9F1AD.22F5%tobbe@embryo.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: tobbe@embryo.se, kancha2np@yahoo.com
  Subject: Re: replace NULL
  In-Reply-To: <B8D9F1AD.22F5%tobbe@embryo.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