Re: Query On Case structure

From: Haller Christoph <ch(at)rodos(dot)fzk(dot)de>
To: dineshp(at)newgen(dot)co(dot)in (Dinesh Parikh)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Query On Case structure
Date: 2001-10-23 10:15:53
Message-ID: 200110230815.KAA29258@rodos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general 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 '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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thurstan R. McDougle 2001-10-23 10:36:23 Re: Database design?
Previous Message t.ngockhoi 2001-10-23 09:18:39 Table and Fields comment

Browse pgsql-sql by date

  From Date Subject
Next Message Doug McNaught 2001-10-23 13:01:59 Re: Index of a table is not used (in any case)
Previous Message Reiner Dassing 2001-10-23 07:01:04 Re: Index of a table is not used (in any case)