pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dinesh Parikh <dineshp@newgen.co.in>
To: pgsql-general@postgresql.org
To: pgsql-sql@postgresql.org
Subject: Query On Case structure
Date: Sat, 20 Oct 2001 19:05:26 +0530
Message-ID: <001401c1596c$13af7350$f005a8c0@dinesh> (raw)

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

view thread (2+ messages)

Message-ID: <001401c1596c$13af7350$f005a8c0@dinesh>
Permalink:  ../001401c1596c$13af7350$f005a8c0@dinesh/
Also on:    postgresql.org/message-id/001401c1596c$13af7350$f005a8c0@dinesh

 · 

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: dineshp@newgen.co.in, pgsql-general@postgresql.org
  Subject: Re: Query On Case structure
  In-Reply-To: <001401c1596c$13af7350$f005a8c0@dinesh>

* 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