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