I am writing a query that counts the number of records for which the character count is less than 11.
SELECT sum(CASE when LEN(Summary) > 11 then 0 else 1) AS [SummaryErrorCnt],
sum(CASE when LEN(ResolutionNotes) >11 then 0 else 1) AS [ResolutionNotesErrorCnt]
FROM dbo.TicketLog
But I get the error
Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'FROM'.
I am closing the parenthesis correctly.
What am I doing wrong?
You're missing the END
keyword fro the CASE
expressions, eg:
CASE when LEN(Summary) > 11 then 0 else 1 END
^^^-- must close CASE with END
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.