Quantcast
Channel: T-SQL - CASE Statement
Viewing all articles
Browse latest Browse all 3

T-SQL - CASE Statement

$
0
0

 

I need to execute a simple Case Statement.  Strangely, if I include a comparison operator I receive an error message showing a syntax error (Message 102, Level 15).  But the same statement without the operator works jsut fine.

 

Works:

Select LastName, Group =

Case Age

When 15 Then '1'

When 18 Then '2'

Else '20'

From tblAgeGroup

End

 

Does Not Work:

 

Select LastName, Group =

Case Age

When <15 Then '1'

When <18 Then '2'

Else '20'

From tblAgeGroup

End

 

Also, I noticed that this does not work in any other combination of the "When.." clause.

 

Any help is appreciated.

 

Thanks


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images