How to change the returned data in SQL?

  • Dear All,

    I have a simple query, and I need to change the returned data.

    I mean if some row has a value "Bnk", I need to return this value as "BankDep".

    Is this possible in SQL 2005?

    This is my query:

    SELECT INDEX_CODE from TableTest;

    The result: INDEX_CODE

    Default

    Int

    Bnk

    Inv

    I need to display the previous values as

    INDEX_CODE

    Default123

    International

    BankDep

    Investment

  • Use a CASE expression like the example given below:

    SELECT

    CASE INDEX_CODE WHEN 'Bnk' THEN 'BankDep'

    ELSE Index_code

    END AS IndexCode

    from TableTest

    .

  • use the following way:

    select case Index_Code

    when 'Default' then 'Default123'

    when 'Int' then 'International'

    when 'Bnk' then 'BankDep'

    when 'Inv' then 'Investment'

    else Index_Code

    end

    from TableTest

  • Thank You very much.

    I did not know that there is a CASE option in the SQL.

    Thanks a lot

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply