Oracle 从 dual 表中查询返回多行记录

时间:2021-06-28 18:48:46   收藏:0   阅读:0

 select 1 as id,‘是‘ as text from dual
 union all
 select 0 as id ,‘否‘ as text from dual

技术图片

 

 

同时查询出十条数据

select * from dual connect by 0 + level <= 10;

 

按照这个特性计算两个日期之间的工作日:

技术图片
select days, week
  from (select to_date(2010-08-01‘, YYYY-MM-DD‘) + level - 1 as days,
               to_char(to_date(2010-08-01‘, YYYY-MM-DD‘) + level - 1,
                       day‘) as week
          from dual
        connect by to_date(2010-08-30‘, YYYY-MM-DD‘) - level + 1 >=
                   to_date(2010-08-01‘, YYYY-MM-DD))
 where week not in(saturday‘,sunday‘);
技术图片
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!