pg⽇期转周_postgres时间转换函数
1. decode ⽤ case when a=1 then b else c end
2. 最后⼀天  to_date(? +'1 mons'::interval,'yyyy-mm') -1
3. 第⼀天 to_date(?,'yyyy-mm') , date_trunc('month',?)
4.字段别名 加上 as
oracle 时间转换
5.⼦查询⼀定要⽤别名
6.取⼦树 ,postgresql需⼈⾃⼰写函数,或者⽤⼀些有结构特性字段如1.1,1.1.1,1.1.2  来代替
date_trunc 与oracle的trunc很像,还可以
SELECT date_trunc('hour', TIMESTAMP '2001-02-16 20:38:40');
Result: 2001-02-16 20:00:00+00
SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
Result: 2001-01-01 00:00:00+00
8.postgres-当⽇, 带时分秒,now()  oracle- sysdate
9 postgres-当⽇,不带时分秒current_date,oracle  to_char(sysdate,'YYYY-MM-DD)
10.nvl 全部替换成 coalesce  如 coalesce(im.invoiceamount,0)
11.⼩数据位数round,例保留⼀位⼩数 ⽤select round(2.16,1)  Result: 2.2 会四舍五⼊
12 转志数据类型⽤::数据类型,如to_number() 改⽤::numeric
13. 如果取⼦树,不包含⾃⾝,使⽤函数时,第⼆个参数取2,如,getorgantree(?,2)
14.项⽬树函数第⼀个参数是id,其他的如果地区编码,税务机关分别有参数为编码的,如(code,level),参数为id的,如byid(id,level)
15.修改表时,表名不能带别名,如update taxpayer_cognizance_invoice tc  这⾥taxpayer_cognizance_invoice 不能带别名tc

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。