Hi,
I am trying to concatenate three columns of same data type (3,3,4) into one column of same data type (12) by giving the following statement, but i am getting an error.
Select
(PHONE.area_code || PHONE.prefix || PHONE.number) as Ph_nbr AS CHAR(12) from abc;
Please guide me where i am going wrong.
SQL Error
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 232
- Joined: Sat May 07, 2005 2:49 pm
- Location: USA
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Use ":" if doing in trans else use"||"
Try the following
cheers,
ash.
Try the following
Code: Select all
SELECT (t.area_code || t.prefix || t.number) as ph_nbr FROM abc t
ash.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You can't do "AS CHAR(12)". It's not legal as an alias. You use a CAST specification (if necessary) to change data type temporarily. The result of concatenation is necessarily string, so it's probably not necessary in that case.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.