' ='附近的语法不正确

时间:2017-06-28 16:27:46

标签: sql sql-server-2008

DECLARE @COUNT_P INT
DECLARE @COUNT_S INT


SELECT MEMBNO, 
CASE 
WHEN TYPCOD = 'P' THEN @COUNT_P = @COUNT_P + 1
END AS C_P,
CASE 
WHEN TYPCOD = 'S' THEN @COUNT_S = @COUNT_S + 1 
END AS C_S
FROM #TEMP2
GROUP BY TYPCOD

我得到的错误是

  

Msg 102,Level 15,State 1,Line 8   ' ='附近的语法不正确。

2 个答案:

答案 0 :(得分:2)

SELECT MEMBNO, 
SUM(CASE 
WHEN TYPCOD = 'P' THEN 1 ELSE 0  END) AS C_P,
SUM(CASE 
WHEN TYPCOD = 'S' THEN 1 ELSE 0 END) AS C_S
FROM #TEMP2
GROUP BY MEMBNO

答案 1 :(得分:0)

您无法在SQL Server中增加类似的值。 cv::Mat T(4, 4, cv::DataType<float>::type); cv::Mat rot = T(cv::Range(0, 3), cv::Range(0, 3)); cv::Mat trans = T(cv::Range(0, 3), cv::Range(3, 4)); R.copyTo(rot); tvec.copyTo(trans); 或者返回值或设置变量,但不能同时返回两者。

SELECT

如果要设置两种类型的总数,则:

DECLARE @COUNT_P INT;
DECLARE @COUNT_S INT;