/*to_char(dt,‘d‘)-1返回星期几的参数,connect by 层次查询语句 */
--显示2015年一月份周日的日期
select distinct to_char(dt-(to_char(dt,‘d‘)-1),‘yyyy-mm-dd‘) as iw
from (select (to_date(‘2015-1-1‘, ‘yyyy-mm-dd‘) + rownum - 1) dt from dual
connect by rownum <= to_date(‘2015-1-31‘, ‘yyyy-mm-dd‘) -to_date(‘2015-1-1‘, ‘yyyy-mm-dd‘))
group by to_char(dt-(to_char(dt,‘d‘)-1),‘yyyy-mm-dd‘)
order by iw
显示:
1 2014-12-28
2 2015-01-04
3 2015-01-11
4 2015-01-18
5 2015-01-25
时间: 2024-10-05 20:28:05