error after case when statement

  • I've tried a few variations of this, but the error is when I start my from statement: i.e.

    this is my last line of my select statement, tried ending the END w/, ;, etc.

    Case when dbo.IP_FLWSHT_MEAS.FLO_MEAS_ID in ('3040102809', '3040102810', '7073740', '7073730') then 'Breast Milk P.O or Tube' else

    case when dbo.IP_FLWSHT_MEAS.FLO_MEAS_ID in ('3040102811', '304012812') then 'Formula P.O. or Tube' Else 'unknown'

    END

    FROM bla

  • te_<3 (8/11/2015)


    I've tried a few variations of this, but the error is when I start my from statement: i.e.

    this is my last line of my select statement, tried ending the END w/, ;, etc.

    Case when dbo.IP_FLWSHT_MEAS.FLO_MEAS_ID in ('3040102809', '3040102810', '7073740', '7073730') then 'Breast Milk P.O or Tube' else

    case when dbo.IP_FLWSHT_MEAS.FLO_MEAS_ID in ('3040102811', '304012812') then 'Formula P.O. or Tube' Else 'unknown'

    END

    FROM bla

    Try

    Case

    when dbo.IP_FLWSHT_MEAS.FLO_MEAS_ID in ('3040102809', '3040102810', '7073740', '7073730') then 'Breast Milk P.O or Tube'

    when dbo.IP_FLWSHT_MEAS.FLO_MEAS_ID in ('3040102811', '304012812') then 'Formula P.O. or Tube'

    Else 'unknown'

    END



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • OMG, that's it, I had an extra 'else'?

    thank you thank you thank you thank you thank you thank you thank you thank you thank you

  • te_<3 (8/11/2015)


    OMG, that's it, I had an extra 'else'?

    thank you thank you thank you thank you thank you thank you thank you thank you thank you

    You're welcome.

    Extra Else and extra Case.

    SQL Case statement should only have one Case and one Else, unless you're nesting one Case statement inside another.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • after closer examiniation I realize the extra case as well. Thank you...have a good hour + trying varying combinations of ', and "" use to the if then else not case when 🙂

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply