【发布时间】:2014-09-26 15:13:55
【问题描述】:
我正在尝试运行一个可以在 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
但是像往常一样在哪里无法识别Balance?
我们如何解决这个问题?
【问题讨论】:
-
使用子查询或重复表达式或在 MySQL 中使用 having 子句。
-
或者只是在 where 中重复操作:
Where A.Order not Null and V.Fees - Coalesce(V.Payment,0) - Coalesce (V.Adjustment,0) = 0