我有一个这样的 SQL 代码,我将在 .NET 应用程序中使用它,我熟悉 LINQ,但我不知道如何处理 WITH 语句。
WITH records
AS
(
SELECT [key], [rev], [IsCurrent],
ROW_NUMBER() OVER(PARTITION BY [key]
ORDER BY CASE WHEN [rev] = @revNUm
THEN 0 ELSE 1 END) rn
FROM tableName
WHERE [Rev] IN (@revNUm,0)
)
SELECT [key], [rev], [IsCurrent]
FROM records
WHERE rn = 1
编辑: ROW_NUMBER() 似乎也很难,我该怎么做?
谢谢