• mister.magoo (10/10/2013)


    ali.m.habib (10/10/2013)


    I want to select top 1 value either null or value from this query

    select top 1 column5 from table2 where table2.column1ID = 5

    if the whole value of this column is null the return is empty , but I need to return value or null

    SELECT (select top 1 column5 from table2 where table2.column1ID = 5 order by columnID) as column5

    (Added the order by because I don't like to see TOP without ORDER BY ever)

    Well, it seems you win the prize of the shortest statement 🙂

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