好办!
select * from (select * from tablename where substring(你的日期的年月值) a left join
(select * from tablename) b where b.(你的日期的年月值+一个月) = a.(你的日期的年月值)
select * from (select * from tablename where substring(你的日期的年月值) a left join
(select * from tablename) b where b.(你的日期的年月值+一个月) = a.(你的日期的年月值)
因为你只能以7月为主嘛!
7月的天数与6月的天数不近现同!
主要where条件就是
a的20030701 = b.20030601
明白嘛?
你看看ORACLE里的才分字符串是什么
然后用这个搞就行了!
我靠! 就是Substring的功能!
拆分字符串!
select * from
(select * table where 字段名= "拆分出来的前六为" a)
left join
(select * table where 字段名= "拆分出来的前六为" b)
on a.? = (b.?//要出来自负串+1获得和a同一天的值)
(里面的?就是你的取得拆分出来的前六为)
他们能相等吗?再说day是字符型怎么加一???请指教!!!!
上月是20030601吗?我substring 一下得到200306对吧,我加1 不就是 200307对吧!
这就是相等的条件!关键是ORACLE的SUBstring这个函数(看手册有没有,还是其他函数 db2 是substring)再说day是字符型怎么加一???告诉你,oracle里面应该有转型的函数,DB2的好像直接就是(int)String
你的受不了了!
不过日期型的比较我也不会,access里的 。关注oracle里如何比较的。
sweat pqds(一个女农民)
怎么这种问题都贴到这里来。
sweat 楼主
那样你的负担大大的!
oracle绝对有substring类似的方法,你自己看一下手册!