本文介绍了Oracle SQL查询-获取上周(周一至周六)的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个查询,该查询将显示上周(始终从星期一开始)从 COLUMNNAME , TABLENAME .我还有一列带有日期的 adddate .似乎不起作用...我该如何解决?
I'm working on a query that would show data added in last week (always beginning with Monday), from COLUMNNAME, TABLENAME. I also have a column with dates, adddate.It seems not to work... How would I fix it?
select COLUMNNAME
from TABLENAME
where adddate >= (TRUNC(adddate - 7 - (TRUNC (adddate)- TRUNC (adddedate, 'IW'))))
and adddate < (TRUNC(adddate - 7 - (TRUNC (adddate)- TRUNC (adddedate, 'IW'))))+6
推荐答案
我认为您的表达式需要其中的当前日期,例如:
I think your expression needs the current date in it somewhere, such as:
where adddate >= next_day(trunc(sysdate), 'MONDAY') - 14 and
adddate < next_day(trunc(sysdate), 'MONDAY') - 7
这篇关于Oracle SQL查询-获取上周(周一至周六)的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!