CASE Statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dhutton
    New Member
    • May 2007
    • 28

    CASE Statement

    Hello

    How would I go about using the CASE statement with the WHEN and THEN statements with a scenario like this:

    =============== =============== ========---
    CASE PhoneNumber

    WHEN 9990000000 THEN City1
    WHEN 8030000000 THEN City2

    ect...
    =============== =============== =============== =

    What I want to do is check only the first 3 digits - just the 999. There would be 4 different possible first 3 digits:

    999, 997, 998, and 803. Each one of these first 3 digits of the 10 digit phone number identifies a city

    What I would like to do is iether use a wild card - like this:

    CASE PhoneNumber
    WHEN LIKE (999%) THEN City1

    OR try something like taking the first 3 numbers and assigning it to a variable then doing the CASE statrement like this:

    TAKE PhoneNumber 3 and asign it to CHK_NUM

    CASE CHK_NUM
    WHEN '999' THEN 'City1'

    Any ideas would be greatly appriciated

    Thanks!
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    If you know the solution, what is the problem then.

    Comment

    • dhutton
      New Member
      • May 2007
      • 28

      #3
      I don't know the solution. My examples do not have the correct syntax - that's what I'm looking for. What would the correct string look like for the solution?

      Thanks

      Comment

      • dhutton
        New Member
        • May 2007
        • 28

        #4
        OK - Never Mind, you were right, I had the solution - it works!

        Thanks

        Comment

        Working...