pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Haller Christoph <ch@rodos.fzk.de>
To: dineshp@newgen.co.in
Cc: pgsql-sql@postgresql.org
Subject: Re: Query On Case structure
Date: Tue, 23 Oct 2001 10:15:53 METDST
Message-ID: <200110230815.KAA29258@rodos> (raw)
In-Reply-To: <001401c1596c$13af7350$f005a8c0@dinesh>


> 
> Hi All,
> Can we create a query to find different values based on different criteria =
> from a table using case structure. For example
> 
 Select Into :DBComment
         Case When localComment Is Null Then Comment
              When localComment = '123' Then 'Numeric Comment'
              Else 'String Comment'
         End
 from PDBUser
 Where UserIndex = 23;
> 
> Using such type of structure can we evaluate multiple values. e.g
> 
 Select DBComment , DBName, 
         Case When localComment Is Null Then Comment
              When localComment = '123' Then 'Numeric Comment'
              Else 'String Comment'
         End,
         Case When localName Is Null Then UserName
              When localName = 'SuperUser' Then 'Supervisor'
              Else 'NormalUser'
         End
 from PDBUser
 Where UserIndex = 23;
> 
> 
> Is this possible. If yes then How is it.
> Any help/suggestion may be benificial.
> 
> Regards
> Dinesh Parikh
> NSTL New Delhi
> 
Looks fine to me. What do you want by asking "If yes then How is it." 
Run the query and have a look on the result. 
Regards, Christoph 



view thread (2+ messages)  latest in thread

Message-ID: <200110230815.KAA29258@rodos>
Permalink:  ../200110230815.KAA29258@rodos/
Also on:    postgresql.org/message-id/200110230815.KAA29258@rodos

 · 

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: ch@rodos.fzk.de, dineshp@newgen.co.in
  Subject: Re: Query On Case structure
  In-Reply-To: <200110230815.KAA29258@rodos>

* 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