一尘不染

替换LEFT OUTER JOIN中返回的空值

sql

SELECT        WO_BreakerRail.ID, indRailType.RailType, indRailType.RailCode, WO_BreakerRail.CreatedPieces, WO_BreakerRail.OutsideSource, WO_BreakerRail.Charged, WO_BreakerRail.Rejected, WO_BreakerRail.RejectedToCrop, WO_BreakerRail.Date
FROM            indRailType LEFT OUTER JOIN
                         WO_BreakerRail ON indRailType.RailCode = WO_BreakerRail.RailCode AND WO_BreakerRail.Date = @date

返回时,“日期”列中为NULL值,其中没有来自WO_BreakerRail的匹配行。有没有办法用@date替换那些NULL值?


阅读 147

收藏
2021-05-23

共1个答案

一尘不染

在oracle和sql server中,可以使用COALESCEoracle
version
)函数

SELECT ...., COALESCE(WO_BreakerRail.Date, @date)
2021-05-23