locked
Please Help!!! RRS feed

  • Question

  • I have been trying to figure out why this expression will not work.  My table has multiple statuses.  I would like closed items to fall under closed, terminated to fall under terminated and all others to fall under open.  I get a magnitude of errors when I try to use the OR operator.  So I came up with expression below but I keep getting an error that says: "Incorrect syntax near "=".  Please help!!

    Case when ( [Request.Request.Status] ) != 'closed' then 'Open'
    when 'Open' = ([Request.Request.Status] != 'closed') AND ([Request.Request.Status] = 'terminated') then 'Terminated'
    when ( [Request.Request.Status]) = 'closed' then 'Closed'
    end

    I also wrote one where the second line was:
    when ( [Request.Request.Status] != 'closed') AND ( [Request.Request.Status] = 'terminated') then 'Terminated'
    --this had an error message, too

     

    Thursday, July 9, 2009 9:05 PM

Answers

  • hi
         well u can try the following code,
    select 
    Case when ( [Request.Request.Status]  != 'closed') then 'Open'
    when ('Open' = [Request.Request.Status]) AND ([Request.Request.Status] = 'terminated') then 'Terminated'
    when ( [Request.Request.Status]) = 'closed' then 'Closed'
    end
    
     
    for  the last expression u have not include the end keyword so that its getting the error msg
     correct state is

    select case when ( [Request.Request.Status] != 'closed') AND ( [Request.Request.Status] = 'terminated') then 'Terminated' end




    hope this will help u

    thanx
    • Proposed as answer by Amit Shrivastava Friday, July 10, 2009 5:47 AM
    • Marked as answer by LadyJHand Friday, July 10, 2009 2:38 PM
    Friday, July 10, 2009 5:46 AM

All replies

  • That does not look like VB.net code
    Coding for fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
    Thursday, July 9, 2009 9:23 PM
  • The code you posted here look like pseudocode, so i can't tell which language it belong to 
    kaymaf


    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    Thursday, July 9, 2009 9:30 PM
  • Yes, this is definitely not VB. Looks more like Sql?

    If so, Sql uses <> not != for not equal. (Unless it is Oracle SQL?)


    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    Thursday, July 9, 2009 10:17 PM
  • maybe


    CASE WHEN ( [Request.Request.Status] ) = 'Open' THEN 'Open'
    WHEN ([Request.Request.Status] = 'terminated') THEN 'Terminated'
    ELSE 'Closed'
    END



    Thats how I'd answer it if I was in a SQL forum :-)
    • Edited by TechNoHick Friday, July 10, 2009 1:23 AM
    Friday, July 10, 2009 1:19 AM
  • hi
         well u can try the following code,
    select 
    Case when ( [Request.Request.Status]  != 'closed') then 'Open'
    when ('Open' = [Request.Request.Status]) AND ([Request.Request.Status] = 'terminated') then 'Terminated'
    when ( [Request.Request.Status]) = 'closed' then 'Closed'
    end
    
     
    for  the last expression u have not include the end keyword so that its getting the error msg
     correct state is

    select case when ( [Request.Request.Status] != 'closed') AND ( [Request.Request.Status] = 'terminated') then 'Terminated' end




    hope this will help u

    thanx
    • Proposed as answer by Amit Shrivastava Friday, July 10, 2009 5:47 AM
    • Marked as answer by LadyJHand Friday, July 10, 2009 2:38 PM
    Friday, July 10, 2009 5:46 AM
  • I must be reading it wrong

    if Request.Request.Status is not 'closed' then it will return 'Open'

    if Request.Request.Status is 'terminated' then it will return 'Open' because Request.Request.Status isn't 'closed'
                 it will never return 'Terminated' because it will never equal 'Open' and 'terminated'

    if Request.Request.Status is 'closed' it will return 'Closed'
    Friday, July 10, 2009 6:41 PM