当前位置:首页 > 数据库 > Oracle

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

原文:https://www.cnblogs.com/docstrange/p/13680889.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐