October 15, 2008 at 3:14 am
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
October 15, 2008 at 3:42 am
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
.
October 15, 2008 at 3:52 am
use the following way:
selectcaseIndex_Code
when'Default'then'Default123'
when'Int'then'International'
when'Bnk'then'BankDep'
when'Inv'then'Investment'
elseIndex_Code
end
fromTableTest
October 15, 2008 at 3:56 am
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