“金额1"在使用它的上下文中无效 [英] "AMOUNT1" is not valid in the context where it is used
本文介绍了“金额1"在使用它的上下文中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在 DB2 中执行以下查询:
I'm executing the the following query in DB2:
select
SUM (orders.totalproduct
+orders.TOTALTAX
+orders.totalshipping
-orders.totaladjustment) as amount1
from
orders
where
amount1>10000
查询没有被执行,我得到了这个异常:
The query is not executed, I get this exception instead:
AMOUNT1"在使用它的上下文中无效.SQLCODE=-206,SQLSTATE=42703,DRIVER=3.64.96 SQL 代码:-206,SQL 状态:42703
"AMOUNT1" is not valid in the context where it is used.. SQLCODE=-206, SQLSTATE=42703, DRIVER=3.64.96 SQL Code: -206, SQL State: 42703
我做错了什么?
推荐答案
DB2中不能同时创建和使用amount1.
You can't create and use amount1 in same time in DB2.
试试这个:
select * from (
select SUM (orders.totalproduct+orders.TOTALTAX+orders.totalshipping- orders.totaladjustment) as amount1 from orders
) tmp where amount1>10000
或者这个:
select SUM (orders.totalproduct+orders.TOTALTAX+orders.totalshipping- orders.totaladjustment) as amount1 from orders
having SUM (orders.totalproduct+orders.TOTALTAX+orders.totalshipping-orders.totaladjustment)>10000
这篇关于“金额1"在使用它的上下文中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文