我的Case语句引发此错误的原因:
- 消息102,级别15,状态1,行2‘=’附近的语法不正确。*
代码:
Create PROCEDURE [dbo].[Chart_SelectSmsComplaintsValidity]
@FromDate datetime,
@ToDate datetime
AS
BEGIN
Select COUNT(ReceivedMessages.ID) As ReceivedMessageID,
CASE ReceivedMessages.IsComplaint WHEN ReceivedMessages.IsComplaint=0
THEN 'Incomplete'
WHEN ReceivedMessages.IsComplaint=1 THEN 'Complete'
WHEN ReceivedMessages.IsComplaint=-3 THEN 'Inappropriate' END from ReceivedMessages
where ReceivedMessages.ReceivedDateTime >= @FromDate AND ReceivedMessages.ReceivedDateTime <= @ToDate
Group By ReceivedMessages.IsComplaint
END
2条答案
按热度按时间txu3uszq1#
您组合了两种不同形式的
CASE
语句。您可以这样简化它,因为您在每种情况下都比较相同的表达式:另一种选择是:
6l7fqoea2#
错误在此行中
应该是这样的