DB2 AS/400 系列 在 where 子句中使用别名 [英] DB2 AS/400 iseries Use alias in where clause

查看:18
本文介绍了DB2 AS/400 系列 在 where 子句中使用别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 where 子句中使用列的别名.例如:

I'm trying to use the alias of a column in the where clause. for example:

SELECT col1 AS alias1, col2 + col3 as sums 
FROM my_table
WHERE sums > 10

然后我收到一条错误消息:

But then I get an error message saying:

列总和不在指定表中.

有没有我可以做到这一点?

Is there anyway I can do this?

推荐答案

如果你真的想在 WHERE 中使用别名,而不是列本身,你可以使用派生表:

If you really want to use alias in WHERE, not the column itself, you can do it with derived table :

SELECT a.* 
FROM
(
  SELECT lmITNO AS Item_Number, lmBANO AS Lot, lmSTAS AS Status, 
  lmRORN AS Order_Number 
  FROM MVXJDTA.MILOMA 
) a
WHERE a.Status = 'CCC'
....

这篇关于DB2 AS/400 系列 在 where 子句中使用别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆