Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    108

    Red face Unanswered: Transact SQL -- how do I "Case >"?

    Hello, I am having some transact SQL problems.

    ALLOWED:
    Code:
    	Column1, 
    	CASE FOO
    		WHEN 1 THEN 'Hello'
    		ELSE 'Goodbye'
    		END as MyValue,
    	Column2
    NOT ALLOWED:
    Code:
    	Column1, 
    	CASE FOO
    		WHEN > 1 THEN 'Hello'
    		ELSE 'Goodbye'
    		END as MyValue,
    	Column2
    The problem seems to be the > symbol. Apparantly the case statement is only for equality checks, and nothing else.

    So, what can I do to fix this? I have these kinds of comparisons all over.

    ~Le

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Code:
    	Column1, 
    	CASE 
    		WHEN FOO > 1 THEN 'Hello'
    		ELSE 'Goodbye'
    		END as MyValue,
    	Column2
    -PatP

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    108

    Thumbs up

    Quote Originally Posted by Pat Phelan
    Code:
    	Column1, 
    	CASE 
    		WHEN FOO > 1 THEN 'Hello'
    		ELSE 'Goodbye'
    		END as MyValue,
    	Column2
    -PatP
    I do believe we have a winner.

    Thanks Pat, that works perfectly!

    If you played D&D, I'd send you a free book.

    ~The Le

Posting Permissions

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