2013-10-10 69 views
1

我想從這個查詢前1沒有返回null

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

選擇頂部1值null或值,如果此列全值爲null返回的是空的,但我需要返回值或null

回答

3

將您的選擇包裹在另一個選擇中。

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