Reputation: 30
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
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
same is done in this w3schools tutorial W3schools SQL tutorial
how can I achieve the same result in ORACLE?
Upvotes: 0
Views: 2806
Reputation: 152511
The string concatenation operator is ||
in Oracle:
Single quotes must be used here.
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';
Upvotes: 5