Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Posts
    22

    Angry Unanswered: convert access IIF to sql in order by statement

    ive been having a lot of trouble converting this last line from my access database to sql server. i was hoping someone could help



    order by Name, IIF(Risk.Calc like H*, 1, IIF (Risk.Calc like M*,2,3)), Risk.Chance*risk.cons DESC, risk.title


    any suggestions?

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I;m not sure I got the IIF true/False right...I went with IIF(expr, true, false)...if it's backwards just flip it in the code....

    Code:
    ORDER BY   Name
    --	, IIF(Risk.Calc like H*, 1, IIF (Risk.Calc like M*,2,3)), Risk.Chance*risk.cons DESC, risk.title
    	, CASE  WHEN Risk.Calc LIKE 'H%' THEN 1
    		WHEN Riks.Calc LIKE 'M%' THEN 2
    					 ELSE 3
    	  END
    	, Risk.Tile
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Oct 2003
    Posts
    22
    i didnt think you could use IIF in sql

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    I think brett was just reiterating your iif and submitting a case example as the replacement.

  5. #5
    Join Date
    Oct 2003
    Posts
    22
    yea thats what i thought after i looked at it, thanks for the help brett

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    The "--" indicate that it's a comment line...good luck..

    did it work?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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