我已經創建了別名Previousodds列。我想訪問這個列並使用它來返回表的子集。我的查詢是:我如何可以訪問哪些已用CTE創建一個臨時列?
WITH t as
(SELECT
col1,
col2,
col3,
odds,
col4
FROM
stuff)
SELECT *
, LAG(odds,1,0) OVER (partition by [col1] ORDER BY [col2] AS Previousodds
FROM t
-- What I would like to do but can't:
WHERE (1/Odds - 1/Previousodds) > 0.04
裹另一個查詢選擇 – Yossi