postgresql常用实例分享

1.保留小数点。保留小数点,round运算时,必须加 ::numeric

select round(b.num::numeric/b.counts::numeric,4)

2.转日期格式

to_char(t.create_time, 'yyyy')

3.选择语句

case when use_money is not null and download_count is null then -1 else   round(use_money::numeric/download_count::numeric,2) end 
case when use_money is not null  then -1 else   xx end 
(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐