Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to change the returned data in SQL?

How to change the returned data in SQL?

Scheduled Pinned Locked Moved Database
databasetutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    obarahmeh
    wrote on last edited by
    #1

    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

    H P 2 Replies Last reply
    0
    • O 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

      H Offline
      H Offline
      HemJoshi
      wrote on last edited by
      #2

      select case INDEX_CODE when 'Default' Then 'Default123' when 'Int' Then 'International' when 'Bnk' Then 'BankDep' When 'Inv' Then 'Investment' END from TableTest

      O 1 Reply Last reply
      0
      • O 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

        P Offline
        P Offline
        Paddy Boyd
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • H HemJoshi

          select case INDEX_CODE when 'Default' Then 'Default123' when 'Int' Then 'International' when 'Bnk' Then 'BankDep' When 'Inv' Then 'Investment' END from TableTest

          O Offline
          O Offline
          obarahmeh
          wrote on last edited by
          #4

          Thank you very much, I did not knot that there is a CASE option in SQL Thanks a lot

          Kind Regards OBarahmeh

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups