If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Substituting values in a view

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-18-09, 22:52
Bambuk Bambuk is offline
Registered User
 
Join Date: Sep 2008
Posts: 11
Substituting values in a view

I have a table with
Co1 and Col2.
Col2 can have has values "AA", 'BB', and 'CC'.
I have to create a view with those two columns and it should have '01' instead of 'AA' , '02' instead of 'BB' and '03' instead of 'CC'.
How should I code it?
Thanks.
Reply With Quote
  #2 (permalink)  
Old 11-18-09, 22:58
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Use CASE expression.
Reply With Quote
  #3 (permalink)  
Old 11-18-09, 23:00
DB2Plus DB2Plus is offline
Registered User
 
Join Date: Jul 2009
Posts: 150
select case col2 when 'AA' then '01' when 'BB' then '02' when 'CC' then '03' else col2 end
from table1


Kara
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On