Re: Query On Case structure - Mailing list pgsql-sql

From Haller Christoph
Subject Re: Query On Case structure
Date
Msg-id 200110230815.KAA29258@rodos
Whole thread Raw
In response to Query On Case structure  ("Dinesh Parikh" <dineshp@newgen.co.in>)
List pgsql-sql
> 
> 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
'NumericComment'             Else 'String Comment'        Endfrom PDBUserWhere 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'        Endfrom PDBUserWhere
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 


pgsql-sql by date:

Previous
From: Reiner Dassing
Date:
Subject: Re: Index of a table is not used (in any case)
Next
From: Haller Christoph
Date:
Subject: Re: pgsql embedded again!