Oracle 字段为空处理 NVL()函数, NVL2()函数

--1. NVL()函数:
--格式:NVL(E1,E2)
--说明:若E1为NULL,则函数返回E2,否则返回E1本身。
Select NVL(FQty,0) as qty From T_Sal_Order --如果FQty的值为null,则返回 0
Select NVL(FQty,FAssistQty) as qty From T_Sal_Order --如果FQty的值为null,则返回 FAssistQty
Select NVL(FDescription, '无') as description From T_INF_Message --如果FDescription的值为null,则返回 无


--2. NVL2()函数:
--格式:NVL2(E1, E2, E3)
--说明:若E1为NULL,则函数返回E3,若E1不为null,则返回E2。
Select NVL2(FQty,1,0) as qty From T_Sal_Order --如果FQty的值为null,则返回 0, 不为null则返回1
Select NVL2(FDescription,'有','无') as description From T_INF_Message --如果FDescription的值为null,则返回 无, 不为null则返回 有

猜你喜欢

转载自blog.csdn.net/qq_25170493/article/details/86304907
今日推荐