locked
IF Cases In Where Clause RRS feed

  • Question

  • Hi

    can we use IF () in where clause more than 3

    Thanks

    Sandeep


    Sandeep Kumar

    Wednesday, October 31, 2012 9:27 AM

Answers

All replies

  • No if clause.. but you can use CASE When..

    vt


    Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker

    Wednesday, October 31, 2012 9:29 AM
  • You should use IIF() not IF. See this

    http://msdn.microsoft.com/en-us/library/hh213574.aspx


    Many Thanks & Best Regards, Hua Min



    • Edited by Jackson_1990 Wednesday, October 31, 2012 3:18 PM
    Wednesday, October 31, 2012 9:32 AM
  • If you mean IIF() function of 2012,  it can be nested 10 levels, the same as underlying CASE.

    http://msdn.microsoft.com/en-us/library/hh213574.aspx

    Serg

    • Proposed as answer by Naomi N Wednesday, October 31, 2012 12:45 PM
    • Marked as answer by Iric Wen Tuesday, November 6, 2012 8:46 AM
    Wednesday, October 31, 2012 9:36 AM
  • If you mean IIF() function of 2012,  it can be nested 10 levels, the same as underlying CASE.

    Stick to ANSI/ISO Standard CASE expressions and do not use hillbilly dialects. Experienced SQL programmers will laugh at you if you don't. 


    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL

    Wednesday, October 31, 2012 12:45 PM