select * from ( with x as ( select trunc(to_date('2012-9-28','yyyy-mm-dd')+level,'dd') +level-1 day ,to_char(to_date('2012-9-28','yyyy-mm-dd')+level,'dy') weekday from dual connect by level <= 28 )select rownum id,x.* from x where weekday not in ('星期六','星期日')
select * from all_date where all_date_year>=2012 and all_date_month>=9 and all_date_day>=28 --往后查找 and day_is_work=1 --限定工作日 and rownum=20 --刚好是第20个工作日 order by all_date_year,all_date_month,all_date_day
大概是这样的吧 你调试看下对不对追问
这样肯定不对的,2013年大于9的月份岂不是全没了。我感觉用游标或存储过程比较好。只是我写不对了
追答
那你就把年月日拼接成字符串 然后再转为日期型 然后再过滤就是了
我觉得你的表结构设计不合理 为什么不放一个日期上去呢?这样做比较筛选不好么。
本回答被网友采纳
第2个回答 2013-01-10
select * from all_date where all_date_year>=2012 and all_date_month>=9 and all_date_day>=28 --你给定的日期 and day_is_work=1 --限定工作日 and rownum=20 --刚好是第20个工作日 order by all_date_year,all_date_month,all_date_day追问