Results 1 to 4 of 4

Thread: case stmt

  1. #1
    Join Date
    Oct 2003
    Posts
    22

    Unanswered: case stmt

    the syntax is

    CASE xxxxxx
    WHEN yyyyy THEN zzzz
    ..............;

    CAN WE USE IT AS

    CASE xxxxxx
    LIKE yyyyy THEN zzzz
    ..............;

    Thank you
    stephen

  2. #2
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi,

    I believe so...

    select code, case when code like 'SA%' then 'Sales' else 'Other' end from reasons

    Hth
    Bill
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

  3. #3
    Join Date
    Oct 2003
    Posts
    22
    no u got me wrong.

    its not

    CASE
    WHEN a LIKE b1 THEN c1
    WHEN a LIKE b2 THEN c2
    ....................;

    its

    CASE a
    LIKE b1 THEN c1
    LIKE b2 THEN c2
    ..........;
    or of the similar format.

    TY

  4. #4
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi,

    I don't know about other versions but on 8, no, that's not allowed. The format is

    CASE
    WHEN <condition> THEN <expr>
    WHEN <condition> THEN <expr>
    ......
    ELSE
    END

    The structure you suggest (as is common in 'C'/Pascal etc) is not supported.

    Hth
    Bill
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •