Trying to change my results in a query using case statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Leftee08
    New Member
    • Apr 2013
    • 2

    Trying to change my results in a query using case statement

    Hi. I have a fairly simple query and I need to change the name of the results in one field. I have a field called ' Org'. This field has three options. Conasp, Mexico and aspen. I have the following case statement but it won't work.

    Case
    When org = 'conasp' then ' Utica'
    When org = ' aspen' then ' Denver'
    When org = ' Mexico' then 'Mexico'

    Else ' null'

    End

    Can someone help me? My query runs it just will not change the names. It uses the original names.

    Thank you !!
  • vijay6
    New Member
    • Mar 2010
    • 158

    #2
    Hey Leftee08, you've to use like this,

    Code:
    CASE org
    WHEN 'conasp' THEN 'Utica'
    WHEN 'aspen' THEN 'Denver'
    WHEN 'Mexico' THEN 'Mexico'
    ELSE 'null'
    END

    Comment

    • Leftee08
      New Member
      • Apr 2013
      • 2

      #3
      Thank you so much. It was driving me crazy. I knew it was something small like that. It works great now.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32653

        #4
        To understand the situation I can say that you could have just changed the first line to :
        Code:
        CASE TRUE
        The code suggested in post #2 makes better sense in your situation though.

        PS. I changed the title of the thread as the original gave a false idea of what the question was about.

        Comment

        Working...