WITH xyz
AS
(
SELECT col1, col2, col3, col4,
ROW_NUMBER() OVER (PARTITION BY col1, col2, col3, col4 ORDER BY col1, col2, col3, col4) as RowNumber
FROM table1
)
试图让上面的代码在microsoft SQL 2008中运行,但它在'('附近不断给出语法错误 无法弄清楚出了什么问题
答案 0 :(得分:0)
我想你之后正在使用那个CTE,所以尝试在WITH
语句之前添加一个分号,如下所示:
;WITH xyz
AS
(
SELECT col1, col2, col3, col4,
ROW_NUMBER() OVER (PARTITION BY col1, col2, col3, col4 ORDER BY col1, col2, col3, col4) as RowNumber
FROM table1
)
使用CTE时,必须使用分号关闭上一个语句。如果您还没有这样做,请尝试在右括号后添加SELECT * FROM xyz
。