可能重复:
为什么我使用过一次后无法访问我的 CTE?
如何使用 WITH 获得多个结果?
;WITH X AS
(SELECT whatever)
, Y AS
(SELECT whatever FROM X)
SELECT * FROM Y WHERE condition
SELECT Count(*) FROM X <==== X doesn't work here
我不想要@@RecordCount,这算Y,而不是X
可能重复:
为什么我使用过一次后无法访问我的 CTE?
如何使用 WITH 获得多个结果?
;WITH X AS
(SELECT whatever)
, Y AS
(SELECT whatever FROM X)
SELECT * FROM Y WHERE condition
SELECT Count(*) FROM X <==== X doesn't work here
我不想要@@RecordCount,这算Y,而不是X