#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0

    Trying to execute another if, else statement


    I’m trying to execute a query that will look at the column “Account_Type” and say if

    If account type field is Other Current Asset, Other Current Liability, Accounts Payable, Accounts Receivable, Bank, Fixed Asset, Credit Card, Long term Liability, Other asset, Equity then ZLMOVTYPE = ‘F99’ and If account type field is Cost of Goods Sold, Income, Expense, Other Expense, Other Income then ZLMOVTYPE=‘PL99’, Else null.

    This is what I got just trying to test on one item and I get error, what should it be?

    select case when Account_Type = (Accounts Payable),
    then ‘F99'
    else ‘NULL'
    end AS ZLMOVETYPE
    from dbo.YTD_2011_QB_TEST
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    Paris Uppland
    Posts
    2,377
    Rep Power
    391
    Code:
    select case when Account_Type =  'Accounts Payable' 
        then ‘F99' else NULL end AS ZLMOVETYPE
      from dbo.YTD_2011_QB_TEST
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    4
    Rep Power
    0
    Thanks, I executed that code and got the following:


    Msg 102, Level 15, State 1, Line 2
    Incorrect syntax near '‘'.
    Msg 105, Level 15, State 1, Line 2
    Unclosed quotation mark after the character string ' else NULL end AS ZLMOVETYPE
    from dbo.YTD_2011_QB_TEST
    '.
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,143
    Rep Power
    4274
    Originally Posted by mark1906
    Incorrect syntax near '‘'.
    that's one o' them thar microsoft curly quotes

    replace it with a regular single quote -- on most keyboards it's between the semicolon and the enter key
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo