select trunc(to_number(trunc(sysdate + 7 - (case
when to_char(sysdate, 'd') = '7' then
'6'
when to_char(sysdate, 'd') = '1' then
'7'
else
to_char(sysdate - 1, 'd')
end),
'd') - trunc(sysdate, 'mm')) / 7 + 1)
from dual
when to_char(sysdate, 'd') = '7' then
'6'
when to_char(sysdate, 'd') = '1' then
'7'
else
to_char(sysdate - 1, 'd')
end),
'd') - trunc(sysdate, 'mm')) / 7 + 1)
from dual