Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 CASE statement syntx problems

Author  Topic 

Jannette
Starting Member

26 Posts

Posted - 2011-08-31 : 09:03:49
I have written the following CASE syntax, but it is giving an error,

Can you help please?
===================================================================
Case
When (CANDIDATE.Branch_Id=2 and CANDIDATE.Division_Id<>2) Then '"OSS"'
When (CANDIDATE.Branch_Id=2 and CANDIDATE.Division_Id=2) Then '"OES"'
When (CANDIDATE.Branch_Id=3 and CANDIDATE.Division_Id=27) Then '"RPO"'
When (CANDIDATE.Branch_Id=3 and CANDIDATE.Division_Id In (7,15) Then '"OWB"'
Else '"???"' End as Division,
===================================================================

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-31 : 09:09:56
[code]Case
When (CANDIDATE.Branch_Id=2 and CANDIDATE.Division_Id<>2) Then '"OSS"'
When (CANDIDATE.Branch_Id=2 and CANDIDATE.Division_Id=2) Then '"OES"'
When (CANDIDATE.Branch_Id=3 and CANDIDATE.Division_Id=27) Then '"RPO"'
When (CANDIDATE.Branch_Id=3 and CANDIDATE.Division_Id In (7,15)) Then '"OWB"'
Else '"???"' End as Division
[/code]


you missed a )

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Jannette
Starting Member

26 Posts

Posted - 2011-08-31 : 09:21:10
Thankyou, silly me.

Time for a coffee break I think.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-31 : 10:13:33
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -