cadill on Mosio
cadill
Boston guy

Name: Cadill
Location: Boston
Web: twitter.com/cadill

11 Qs, 9 As, 0 FYIs
1 in cadill's Qniverse:
Fixitfox
Buy a Mosio T-Shirt!
Question
I have a table in my database with a field that contains a single character: 'Y' or 'N'. I'm doing a SELECT query in SQL Plus, for example: SELECT Answer from Table; N N Y N Y I want my SELECT query to return the full word 'Yes' for Y and 'No' for 'N', like this: No No Yes No Yes How do I format the SELECT query to output that way? Thanks, Cadill Join or Log In to answer.
depends on your DBMS, but for MS SQL SERVER you could do:
select TOP 10 replace(replace(Answer,'Y','Yes'),'N','No') from Table
-MattEvans16 (5Q / 120A) Wed Jan 16, 2008 12:04pm

Comments:
Interesting. I'm querying Oracle using SQL Plus. Probably something similar?
-cadill (11Q / 9A) Wed Jan 16, 2008 12:16pm

(To cadill)
Should be identical, SELECT REPLACE('Some Phrase','OldValue','NewValue') From Table

http://www.psoug.org/reference/translate_replace.html
-MattEvans16 (5Q / 120A) Wed Jan 16, 2008 12:24pm

(To MattEvans16)
ROCK ON! Yes, you're right. It worked. THANKS!
-cadill (11Q / 9A) Wed Jan 16, 2008 12:46pm


(without the 'TOP 10', I used that because I was testing it on a table with 500,000+ records)
-MattEvans16 (5Q / 120A) Wed Jan 16, 2008 12:09pm

Comments:
somehow I thought this would be a question for you to answer. but, get back to work. =P
-skinnedmink (39Q / 85A) Wed Jan 16, 2008 12:13pm

(To skinnedmink)
haha, I am working, just got situated in LittleRock, I can't goto the Y, gone till Friday Afternoon
-MattEvans16 (5Q / 120A) Wed Jan 16, 2008 12:27pm


Permalink AddThis Social Bookmark Button

AddThis Feed Button