View previous topic :: View next topic
|
Author |
Message |
itjagadesh
New User
Joined: 05 Dec 2006 Posts: 89 Location: chennai
|
|
|
|
Hi,
I need to retrieve a integer column as char(2) and I'm using this
char(char(Integer_column),2) syntax, now the results are retrieved as below
1
2
3
4
5
10
11
12
20
Now, I need to prefix single digit results with '0' so result should be like
01
02
03
04
05.
Could anyone suggest a query to achieve the expected results?
Thanks in advance,
Jagadesh. |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Try to use Length and concat function along with case.
Code: |
CASE WHEN LENGTH(yourcolumn) =1
THEN CONCAT(0,yourcolumn)
ELSE
yourcolumn
END
|
|
|
Back to top |
|
|
itjagadesh
New User
Joined: 05 Dec 2006 Posts: 89 Location: chennai
|
|
|
|
It's working now.
Thank you Bharath! |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
You're Welcome. |
|
Back to top |
|
|
|