SQL Replace Function Problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MindBender77
    New Member
    • Jul 2007
    • 233

    SQL Replace Function Problems

    I have DB2 V7 for IBM. I have a simple select statement which produces 2 columns. Column 2 is smallint. I need col2 to say Picking instead of 720 or Verify instead of 740. Both 720 and 740 can be in the same result set. This is what I have so far. Any help will be greatly appreciated.

    Select col1, varchar(replace ('720', '720', 'Picking'), 10) from table1
  • ties
    New Member
    • Nov 2007
    • 6

    #2
    Try using a 'CASE' expression.

    In your example it would go something like:

    SELECT
    col1,
    CASE col2
    WHEN <value1> THEN '<description1> '
    WHEN <value2> THEN '<description2> '
    ...
    END
    FROM ...

    You can do a lot more with CASE, but this should answer your question.

    Comment

    Working...