简体   繁体   English

DB2 SQL全选带列为

[英]DB2 SQL Select All With Columns As

I am working with some SQL queries on DB2. 我正在使用DB2上的一些SQL查询。 Is it possible to select all the columns in a table and also specify certain conditions using the "as" keyword within that select statement? 是否可以选择表中的所有列,并使用该select语句中的“ as”关键字指定某些条件? For example, is this query possible: 例如,此查询是否可能:

select
  *,
  col1 + col2 as sum1,
  col3 - col4 as dif1
from 
  table;

Whenever I attempt this, I am getting the SQL0104 error and it is saying "Token , was not valid. Valid tokens: FROM INTO". 每当我尝试执行此操作时,都会收到SQL0104错误,并说“令牌无效。有效令牌:FROM INTO”。

Thank you for your help. 谢谢您的帮助。

EDIT: This query is running inside an SQLRPGLE program on an AS400. 编辑:此查询在AS400上的SQLRPGLE程序中运行。

Put your table alias in front of the *. 将您的表别名放在*前面。 So: 所以:

select
  t.*,
  col1 + col2 as sum1,
  col3 - col4 as dif1
from 
  table t;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM