Can i put a select in an ISNULL Statement?

  • crude example,
    the REAL price might not be in DBO.RealPrice,but it will be in DBO.OLDPRICE.

    Can i do something like this:

    Select
    yada A,
    yada B,
    ,ISNULL(RealPrice, Select OLDPRIOE from DBO.OLDPRICE...)

    trying to save some time

  • Have a look a coalesce and see if it meets your needs MS coalesce article

  • You can but only if the sub query will only return 1 or no rows.

  • jeffshelix - Thursday, March 8, 2018 11:48 AM

    crude example,
    the REAL price might not be in DBO.RealPrice,but it will be in DBO.OLDPRICE.

    Can i do something like this:

    Select
    yada A,
    yada B,
    ,ISNULL(RealPrice, Select OLDPRIOE from DBO.OLDPRICE...)

    trying to save some time

    Yes, but why would you want to?

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • yea, I think i over thought this . . . agreed,  thanks , Solved

Viewing 5 posts - 1 through 4 (of 4 total)

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