• Sean Lange (10/10/2013)


    Here is another way without using the ROW_NUMBER window function.

    select top 1 column5 from

    (

    SELECT [column5], 1 as SortOrder FROM [dbo].[table2] WHERE [column1ID] = 5

    UNION

    SELECT NULL, 2

    )x order by SortOrder

    Tried it as well, but somehow managed to get a different result (see first reply where I deleted my query).

    Must've messed it up somehow.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP