November 13, 2015 at 4:49 am
Hi
I have a column that has values [1,2,3....10,11,13,14 ...]
I want to return just two characters, e.g [01, 02, 03....10,11,12...]
I concatenated a string before to
'0'||CAST(m.d_depend as varchar(2)) as 'depend'
but then I would get three character e.g [010,011,012...]
How do I solve this
November 13, 2015 at 4:53 am
Use the RIGHT() function.
Right('0' + col,2)
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
November 13, 2015 at 9:28 am
hoseam (11/13/2015)
HiI have a column that has values [1,2,3....10,11,13,14 ...]
I want to return just two characters, e.g [01, 02, 03....10,11,12...]
I concatenated a string before to
'0'||CAST(m.d_depend as varchar(2)) as 'depend'
but then I would get three character e.g [010,011,012...]
How do I solve this
That syntax seems like a combination from Oracle and SQL server.
November 13, 2015 at 1:10 pm
Luis Cazares (11/13/2015)
hoseam (11/13/2015)
HiI have a column that has values [1,2,3....10,11,13,14 ...]
I want to return just two characters, e.g [01, 02, 03....10,11,12...]
I concatenated a string before to
'0'||CAST(m.d_depend as varchar(2)) as 'depend'
but then I would get three character e.g [010,011,012...]
How do I solve this
That syntax seems like a combination from Oracle and SQL server.
That is definitely Oracle syntax. The || is the concatenation operator in Oracle.
Regarding the problem, what happens if your numbers get up to 3 digits in length? What if you have [1,2,,,5,6] as one of your strings?
For a great string splitter function, see the link in my signature. I don't know if it'll work in Oracle because I've never tried.
November 13, 2015 at 1:18 pm
Ed Wagner (11/13/2015)
Luis Cazares (11/13/2015)
hoseam (11/13/2015)
HiI have a column that has values [1,2,3....10,11,13,14 ...]
I want to return just two characters, e.g [01, 02, 03....10,11,12...]
I concatenated a string before to
'0'||CAST(m.d_depend as varchar(2)) as 'depend'
but then I would get three character e.g [010,011,012...]
How do I solve this
That syntax seems like a combination from Oracle and SQL server.
That is definitely Oracle syntax. The || is the concatenation operator in Oracle.
But Oracle uses varchar2 instead of varchar and TO_CHAR() instead of CAST().
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply