Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case statement in a select? 1

Status
Not open for further replies.
Dec 13, 2002
109
0
0
GB
Hi

I am wondering if its possible to use a case statement in a select query. For example I have a field that contains 3 possible values A,B or C. As I select these fields I want to display a different value as thus:

A = X
B = Y
C = Z

I thought something like:

SELECT 'status' = CASE WHEN Field = 'A' THEN 'X' WHEN Field = 'B' THEN 'Y' WHEN Field = 'C' THEN 'Z' END)

But this doesnt seem to work?
 
Try this:
Code:
Select  Status = Case Field When 'A' Then 'X' When 'B' Then 'Y' When 'C' Then 'Z' End
HTH,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top