Query On Case structure

Started by Dinesh Parikhover 24 years ago2 messagesgeneral
Jump to latest
#1Dinesh Parikh
dineshp@newgen.co.in

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

#2Christoph Haller
ch@rodos.fzk.de
In reply to: Dinesh Parikh (#1)
Re: Query On Case structure

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