對(duì)于null通過(guò)函數(shù)進(jìn)行轉(zhuǎn)換
字符串(varchar): COALESCE( 字段名,'')
金額(DECIMAL): COALESCE( 字段名,0.00)
整數(shù)(BIGINT): COALESCE( 字段名,0)
時(shí)間: COALESCE(to_char(字段名,'yyyy-mm-dd hh34:mi:ss'),'1900-12-31 00:00:00')
date類型默認(rèn)賦值'1900-12-31', time類型默認(rèn)賦值 '00:00:00',timestamp類型默認(rèn)賦值'1900-12-31 00:00:00'
例如:
FEE DECIMAL,
TOTAL_COUNT BIGINT,
SNAPSHOT_DATE date,
PLATFORM_SIGN varchar
如果在查詢中存在空值,而我不想出現(xiàn)空值,這時(shí)就需要轉(zhuǎn)換一下,(時(shí)間類型根據(jù)業(yè)務(wù)需求來(lái),有的默認(rèn)不一樣)
select COALESCE(to_char(SNAPSHOT_DATE,'yyyy-mm-dd'),'1900-12-31') from 表名;
select COALESCE(TOTAL_COUNT,0) from 表名;
select COALESCE(FEE,0.00) from 表名;
select COALESCE(PLATFORM_SIGN,'') from 表名;
文章題目:COALESCE函數(shù)
分享地址:
http://weahome.cn/article/gphsgj.html