Oracle trunc()函数的用法

select trunc(20171106/100,0) from tabledate --------------结果为201711
select trunc(20171106/10000,0)*100 from tabledate -----结果为201700
两个值相减就是月份了,两表对比查询时,20171106 可以用字段替换,
如:

select *
from tablename a, tabledate b
where a.month =
trunc(b.beg_date / 100, 0) - runc(b.beg_date / 10000, 0) * 100

posted @ 2020-09-16 19:28  七亿星空  阅读(238)  评论(0编辑  收藏  举报