这个是我用的周数写法,你可以参考下
SELECT A.* FROM (
SELECT to_char(dateTime , 'yyyy-mm-dd') KSRQ
, to_char(dateTime+6, 'yyyy-mm-dd') JSRQ
, TO_CHAR(dateTime,'WW') ZS
FROM
( select dateTime,Rownum rn
from
(with t as
(select rownum-1 rn from dual connect by rownum<=10000)
select to_date('2021-01-01','yyyy-mm-dd')+ rn as dateTime
from t
where to_date('2021-01-01','yyyy-mm-dd') + rn < to_date('2021-12-31','yyyy-mm-dd') --查下年份
) b
where to_char(b.dateTime, 'day') = '星期六'
)
) A
where 1=1
${IF(LEN(ZS)==0,"","AND ZS <='"+ZS+"'")} --查询第几周