Sure...
select case substr(status,1,1) -- you're only interested in the first character. when 'a' then 'Active' when 'i' then 'Inactive' when 't' then 'Terminated' end as statustext from stage.tst
However, there are a few disturbing things about this scheme. First, if you have a column that means something, adding a number to the end is not necessarily the best way. In addition, depending on the number of statuses, you may consider turning this column into a foreign key into a separate table.
Based on your comment, you definitely want to turn this into a foreign key. For example,
create table statuses (
Then your request will be
select a.status, b.description from tst a left outer join statuses b on a.status = b.status
Here's a SQL Fiddle to demonstrate.
Ben Sep 29 '12 at 7:43 2012-09-29 07:43
source share