Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123

    Unanswered: Case - When - Then - Else?

    Thanks in advance for your help!
    I have been using very basic SQL statements to return recordsets to my ASP. One that someone gave me a few months ago was the case statement. Until now, I have been using
    Case
    When this Then that
    When day Then night
    When wet Then Dry End as whatever.
    This has been fine because everything has been this, day or wet. Is there a way to do a Case Else that would capture the very few exceptions that fall outside the norm?

    Thanks,
    Lee

  2. #2
    Join Date
    May 2002
    Posts
    299

    Re: Case - When - Then - Else?

    Lee,

    Why not just attach 'else' to your case expression...

    case when 1=1 then 1
    else 0 end

    --
    -oj
    http://www.rac4sql.net


    Originally posted by clinel
    Thanks in advance for your help!
    I have been using very basic SQL statements to return recordsets to my ASP. One that someone gave me a few months ago was the case statement. Until now, I have been using
    Case
    When this Then that
    When day Then night
    When wet Then Dry End as whatever.
    This has been fine because everything has been this, day or wet. Is there a way to do a Case Else that would capture the very few exceptions that fall outside the norm?

    Thanks,
    Lee
    --
    -oj
    http://www.rac4sql.net

  3. #3
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123

    Talking

    Thanks for not starting the reply with HI STUPID as I was unaware that it was as simple as that!
    Again Thanks,
    Lee

  4. #4
    Join Date
    Dec 2002
    Posts
    1,245

    Re: Case - When - Then - Else?

    Yep. See below...

    Code:
    Case
      When this Then that 
      When day Then night
      When wet Then Dry 
      Else Foo
    End as whatever.


    Originally posted by clinel
    Thanks in advance for your help!
    I have been using very basic SQL statements to return recordsets to my ASP. One that someone gave me a few months ago was the case statement. Until now, I have been using
    Case
    When this Then that
    When day Then night
    When wet Then Dry End as whatever.
    This has been fine because everything has been this, day or wet. Is there a way to do a Case Else that would capture the very few exceptions that fall outside the norm?

    Thanks,
    Lee

  5. #5
    Join Date
    Dec 2002
    Posts
    1,245

    Re: Case - When - Then - Else?

    Sorry for the repeat post; somehow I had not seen the responses already in the browser. Very confused...

    Regards,

    Hugh

    Originally posted by hmscott
    Yep. See below...

    Code:
    Case
      When this Then that 
      When day Then night
      When wet Then Dry 
      Else Foo
    End as whatever.

Posting Permissions

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