明天的明天 永远的永远 未知的一切 我与你一起承担 ??

是非成败转头空 青山依旧在 几度夕阳红 。。。
  博客园  :: 首页  :: 管理

PostgreSQL中有以下格式化函数:

Posted on 2020-08-04 09:04  且行且思  阅读(446)  评论(0编辑  收藏  举报
函数返回类型描述例子
to_char(timestamptext) text 把时间戳转成字符串 to_char(current_timestamp, 'HH12:MI:SS')
to_char(intervaltext) text 把间隔转成字符串 to_char(interval '15h 2m 12s', 'HH24:MI:SS')
to_char(inttext) text 把整数转成字符串 to_char(125, '999')
to_char(double precisiontext) text 把实数或双精度转成字符串 to_char(125.8::real, '999D9')
to_char(numerictext) text 把数字转成字符串 to_char(-125.8, '999D99S')
to_date(texttext) date 把字符串转成日期 to_date('05 Dec 2000', 'DD Mon YYYY')
to_number(texttext) numeric 把字符串转成数字 to_number('12,454.8-', '99G999D9S')
to_timestamp(texttext) timestamp with time zone 把字符串转成时间戳 to_timestamp('05 Dec 2000', 'DD Mon YYYY')

 

将字符串转换成double类型(to_number())

 

select count(*) as tt, sum(to_number( length, '999999.9999') ) as x, sum(to_number( area, '9999999.9999') ) as x from szt_road