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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in CASE statement...HELP!!

Status
Not open for further replies.

LongFeiFengWu

Technical User
Nov 9, 2001
98
US
Code:
ThisYear = Year(Now())

SQL = "SELECT "
SQL = SQL & "[JAN]=SUM(CASE [EntryMonth] WHEN '1' THEN [Instance] END), "
SQL = SQL & "[FEB]=SUM(CASE [EntryMonth] WHEN '2' THEN [Instance] END), "
SQL = SQL & "[MAR]=SUM(CASE [EntryMonth] WHEN '3' THEN [Instance] END), "
SQL = SQL & "[APR]=SUM(CASE [EntryMonth] WHEN '4' THEN [Instance] END), "
SQL = SQL & "[MAY]=SUM(CASE [EntryMonth] WHEN '5' THEN [Instance] END), "
SQL = SQL & "[JUN]=SUM(CASE [EntryMonth] WHEN '6' THEN [Instance] END), "
SQL = SQL & "[JUL]=SUM(CASE [EntryMonth] WHEN '7' THEN [Instance] END), "
SQL = SQL & "[AUG]=SUM(CASE [EntryMonth] WHEN '8' THEN [Instance] END), "
SQL = SQL & "[SEP]=SUM(CASE [EntryMonth] WHEN '9' THEN [Instance] END), "
SQL = SQL & "[OCT]=SUM(CASE [EntryMonth] WHEN '10' THEN [Instance] END), "
SQL = SQL & "[NOV]=SUM(CASE [EntryMonth] WHEN '11' THEN [Instance] END), "
SQL = SQL & "[DEC]=SUM(CASE [EntryMonth] WHEN '12' THEN [Instance] END), "
SQL = SQL & "system,EntryYear FROM Outage "
SQL = SQL & "WHERE EntryYear = '"& ThisYear &"' "
SQL = SQL & "GROUP BY system"
objrec.open SQL,objcon,3,3

Syntax error (missing operator) in query expression '[JAN]=SUM(CASE [EntryMonth] WHEN '1' THEN [Instance] END)'.

Any help is greatly appreciated. I have no idea what I'm missing.

"If nothing within you stays rigid, outward things will disclose themselves. Moving, be like water. Still, be like a mirror. Respond like an echo." ~ Bruce Lee
 
Ok, I fixed Error # 1 -

[JAN]=SUM('CASE [EntryMonth] WHEN "& 1 &" THEN [Instance] END ')

Had to add the ' around the Case statement. Ooops.

Error # 2 -

Too few parameters. Expected 12.

"If nothing within you stays rigid, outward things will disclose themselves. Moving, be like water. Still, be like a mirror. Respond like an echo." ~ Bruce Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top