我正在尝试运行一个查询,我可以在where子句
中使用别名例如:
Select V.Fees - Coalesce(V.Payment,0) - Coalesce (V.Adjustment,0) AS Balance
[
the inner join query for the tables
]
Where A.Order not Null and Balance = 0
Order by Name
但像往常一样,它无法在哪里识别平衡?
我们如何解决这个问题?
答案 0 :(得分:0)
要做的事情的唯一方法是将该字段放在CTE中并通过CTE的连接引用它。
答案 1 :(得分:0)
你可以在where子句
中重复表达式Select V.Fees - Coalesce(V.Payment,0) - Coalesce (V.Adjustment,0) AS Balance
[
the inner join query for the tables
]
Where A.Order not Null and (V.Fees - Coalesce(V.Payment,0) - Coalesce (V.Adjustment,0)) = 0
Order by Name