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
Kind Regards OBarahmeh
-
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
Kind Regards OBarahmeh
-
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
Kind Regards OBarahmeh
The first answer will work, but you might want to consider making this a lookup column linked to a table with a descriptive name for your codes - bit more maintainable.
-
select case INDEX_CODE when 'Default' Then 'Default123' when 'Int' Then 'International' when 'Bnk' Then 'BankDep' When 'Inv' Then 'Investment' END from TableTest