Home » SQL & PL/SQL » SQL & PL/SQL » From Integer to String in SQL
From Integer to String in SQL [message #182442] Fri, 14 July 2006 21:09 Go to next message
rushing
Messages: 135
Registered: January 2004
Location: Beijing,China
Senior Member
There is a table like this

ID number
Name number(Cool

The item Name has two values, 0 means 'A', 1 means 'B'.
I want to get the string value by one SQL statement.

For example,
select ID, ... from ...

the result should be
ID NameString
1 'A'
2 'B'
3 'A'

However, I do not want to create another table.
Please teach me.
Thanks!

Re: From Integer to String in SQL [message #182443 is a reply to message #182442] Fri, 14 July 2006 21:14 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Read the fine manual OracleŽ Database SQL Reference WRT DECODE function
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/index.htm#D
Re: From Integer to String in SQL [message #182659 is a reply to message #182442] Mon, 17 July 2006 08:39 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
Why do you think this is an expert question?
icon10.gif  Re: From Integer to String in SQL [message #182757 is a reply to message #182442] Tue, 18 July 2006 01:29 Go to previous messageGo to next message
asherisfine
Messages: 63
Registered: June 2006
Location: India
Member
hi rushing

i think its very very simple

select ID,decode(name,0,'A',1,'B') from <your table>


no wonder why joy_divison wrote


Why do you think this is an expert question? 
Razz
Re: From Integer to String in SQL [message #195078 is a reply to message #182757] Tue, 26 September 2006 21:27 Go to previous message
rushing
Messages: 135
Registered: January 2004
Location: Beijing,China
Senior Member
Thank you!
Previous Topic: plsql Substring function
Next Topic: Oracle 10g Data Pump API using DBLINK
Goto Forum:
  


Current Time: Thu Dec 12 08:56:59 CST 2024