Function Name??

  • Hello Everyone

    I am trying to remember the function name in the SQL Books Online that can be used in a select statement, that if the value in the table is a certain value, return a value, but if not, return something else

    Now that everyone is totally confused 😀

    It is very difficult to look up the function name, when you don't know the function name. Some are pretty easy, like LEN, but for the life of me, I cannot think of the name for this one

    pseudo code:

    IF TypeID > 1

    THEN

    TypeID = 1

    ELSE

    TypeID = 0

    This is as close as I can come in my explanation. TypeID is the column name.

    Thanks

    Andrew SQLDBA

  • CASE

    ie.

    SELECT CASE WHEN Yourvalue IN ('Yes','No','Maybe') THEN YourValue ELSE 'Invalid' END as Result

    From YourTable

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply