CASE statement help

Hello everyone

I am trying to alter one of our stored procedures and SQL is driving me a bit loopy.  I’m trying to put an IF statement inside a CASE statement e.g.

 

case @HoldDetail when 1 then if ps.seat_status = 4 then 1 else 0 end else 0 end,

 

but SQL is having none of it.  Basically I was it to return ‘1’ if @HoldDetail is ‘1’ and ps.seat_status is ‘4’ otherwise it should return ‘0’.

 

Could you help at all?  I’m sure its pretty obvious but beyond my SQL knowledge I’m afraid

 

Thanks everso

 

Graeme

Young Vic Theatre

Parents
  • Hi Graeme – try something like this:

     

    Case when @HoldDetail = 1 and ps.seat_status = 4 then 1 else 0 end…

     

    -Matt

     

    From: Tessitura Technical Forum [mailto:forums-technical@tessituranetwork.com] On Behalf Of Graeme Ellis
    Sent: Tuesday, September 29, 2009 9:37 AM
    To: Matt Cooper
    Subject: [Tessitura Technical Forum] CASE statement help

     

    Hello everyone

    I am trying to alter one of our stored procedures and SQL is driving me a bit loopy.  I’m trying to put an IF statement inside a CASE statement e.g.

     

    case @HoldDetail when 1 then if ps.seat_status = 4 then 1 else 0 end else 0 end,

     

    but SQL is having none of it.  Basically I was it to return ‘1’ if @HoldDetail is ‘1’ and ps.seat_status is ‘4’ otherwise it should return ‘0’.

     

    Could you help at all?  I’m sure its pretty obvious but beyond my SQL knowledge I’m afraid

     

    Thanks everso

     

    Graeme

    Young Vic Theatre




    This message was sent automatically to you by www.tessituranetwork.com because you subscribed to the Tessitura Technical Forum. You may reply to this message to post to the Technical forum or visit the site to search, read and post to the forums. In the interest of keeping the forum posts from becoming cluttered, we encourage you to delete previous message text from your reply before sending. Thank you!

  • Thank you very much Matt and Tanya,

    That worked perfectly

    Grae x

Reply Children
No Data