Error in case statement

Last Post 05 Nov 2010 12:40 PM by donnatamta. 1 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
werice
New Member
New Member

--
05 Nov 2010 11:11 AM
I have the following CASE statement:

CASE Contract_End_Date 
   WHEN MONTH(Contract_End_Date = 10 
   AND OctAmount = 0 Then 8 
   WHEN MONTH(Contract_End_Date) = 11 
   AND NovAmount = 0 Then 7 
   WHEN MONTH(Contract_End_Date) = 12 
   AND DecAmount = 0 Then 6 
   WHEN MONTH(Contract_End_Date) = 1 
   AND JanAmount = 0 Then 5 
   WHEN MONTH(Contract_End_Date) = 2 
   AND FebAmount = 0 Then 4 
   WHEN MONTH(Contract_End_Date) = 3 
   AND MarAmount = 0 Then 3 
   WHEN MONTH(Contract_End_Date) = 4 
   AND AprAmount = 0 Then 2 
   WHEN MONTH(Contract_End_Date) = 5 
   AND MayAmount = 0 Then 1
END As Divisor

I get the error: INCORRECT syntax nerr '='.  And this is the first WHEN statement which I have in bold.  It looks correct
anyone know what the problem is?

Thanks!!!
Bill
donnatamta
New Member
New Member

--
05 Nov 2010 12:40 PM
you don't need column name before WHEN and missing closing parenthesis. SELECT CASE WHEN MONTH(Contract_End_Date) = 10 AND OctAmount = 0 Then 8 WHEN MONTH(Contract_End_Date) = 11 AND NovAmount = 0 Then 7 WHEN MONTH(Contract_End_Date) = 12 AND DecAmount = 0 Then 6 WHEN MONTH(Contract_End_Date) = 1 AND JanAmount = 0 Then 5 WHEN MONTH(Contract_End_Date) = 2 AND FebAmount = 0 Then 4 WHEN MONTH(Contract_End_Date) = 3 AND MarAmount = 0 Then 3 WHEN MONTH(Contract_End_Date) = 4 AND AprAmount = 0 Then 2 WHEN MONTH(Contract_End_Date) = 5 AND MayAmount = 0 Then 1 END As Divisor
You are not authorized to post a reply.

Acceptable Use Policy