Return a value if no rows match

前端 未结 2 360
粉色の甜心
粉色の甜心 2021-01-21 13:29

The [authorityID] (TinyInt) column will never be null.

What I want is to return a 15 if there are no rows. With the query below I

2条回答
  •  感情败类
    2021-01-21 14:18

    SELECT  authorityId = isnull(( SELECT   [authorityID]
                                   FROM     [docAuthority] WITH ( NOLOCK )
                                   WHERE    [grpID] = 0
                                            AND [sID] = 42
                                 ), 15)
    

提交回复
热议问题