[英]Oracle multiple column single Alias
I am trying to select multiple columns and concatenate them in one column with a plus sign and one space on both sides of this plus sign in Oracle 11.2.0.1.0 我正在尝试选择多个列,并在Oracle 11.2.0.1.0中将此列连接在一个带有加号的列中,并且在此加号的两侧都留有一个空格
SELECT ename AS Emplyee_name , deptno AS Department_Number , comm+" + " + sal AS This_Month_Comm_and_sal FROM emp WHERE ename = 'AHMAD';
I am getting this error 我收到此错误
ORA-00904: " + ": invalid identifier
ORA-00904:“ +”:无效的标识符
same is done in this w3schools tutorial W3schools SQL tutorial 在此w3schools教程W3schools SQL教程中也是如此
how can I achieve the same result in ORACLE? 如何在ORACLE中获得相同的结果?
The string concatenation operator is ||
字符串连接运算符为
||
in Oracle: Single quotes must be used here. 在Oracle中:在这里必须使用单引号。
SELECT
ename AS Emplyee_name ,
deptno AS Department_Number ,
TO_CHAR(comm) || ' + ' || TO_CHAR(sal) AS This_Month_Comm_and_sal
FROM emp
WHERE ename = 'AHMAD';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.