我在使用查询将变量的结果存储在变量中时遇到问题。
错误显示WITH附近有错误,然后我尝试使用
之前放置一个半冒号(;)这是我的代码
SET @long2 = WITH QUERY AS (
SELECT LONG, ROW_NUMBER() OVER(ORDER BY philtime desc) AS RowNumber
FROM TblCurrent_ROI where KMRUN IS NULL and LONG is not null and ACCOUNT = @account
)
SELECT LONG FROM QUERY WHERE ROWNUMBER = 2
答案 0 :(得分:1)
WITH QUERY AS (
SELECT LONG, ROW_NUMBER() OVER(ORDER BY philtime desc) AS RowNumber
FROM TblCurrent_ROI where KMRUN IS NULL and LONG is not null and ACCOUNT = @account
)
SELECT @long2 = LONG FROM QUERY WHERE ROWNUMBER = 2