Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

COALESCE function

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

For null to convert through functions

String (varchar): COALESCE (field name,'')

Amount (DECIMAL): COALESCE (field name, 0.00)

Integer (BIGINT): COALESCE (field name, 0)

Time: COALESCE (to_char (field name, 'yyyy-mm-dd hh34:mi:ss'),' 1900-12-31 00 yyyy-mm-dd hh34:mi:ss' 00')

The default assignment for the date type is' 1900-12-31', and the default assignment for the time type is' 1900-12-31 00 'for the timestamp type

For example:

FEE DECIMAL

TOTAL_COUNT BIGINT

SNAPSHOT_DATE date

PLATFORM_SIGN varchar

If there is a null value in the query, and I do not want to have a null value, then you need to convert it. (the time type varies according to business requirements, and some are different by default.)

Select COALESCE (to_char (SNAPSHOT_DATE,'yyyy-mm-dd'), '1900-12-31') from table name

Select COALESCE (TOTAL_COUNT,0) from table name

Select COALESCE (FEE,0.00) from table name

Select COALESCE (PLATFORM_SIGN,'') from table name

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report