zoukankan      html  css  js  c++  java
  • (Oracle)取当前日期的最近工作日

      描述:现有一需求,日期表中存放了日期和是否节假日(0-工作日,1-节假日),现在需要取日期表中的最近的工作日。如2017/07/23(周日)最近的工作日应该是2017/07/21(周五)。
          DATE_D    IS_HOLIDAY
    1    2017/7/17    0
    2    2017/7/18    0
    3    2017/7/19    0
    4    2017/7/20    0
    5    2017/7/21    0
    6    2017/7/22    1
    7    2017/7/23    1
    8    2017/7/24    0
    9    2017/7/25    0
    select t1.date_d,max(t2.date_d)
    from table_a t1 left join table_a t2 on (t1.date_d >= t2.date_d and t2.is_holiday='0')
    group by t1.date_d
    order by t1.date_d

    结果:

          DATE_D    MAX(T2.DATE_D)

    1    2017/7/17    2017/7/17
    2    2017/7/18    2017/7/18
    3    2017/7/19    2017/7/19
    4    2017/7/20    2017/7/20
    5    2017/7/21    2017/7/21
    6    2017/7/22    2017/7/21
    7    2017/7/23    2017/7/21
  • 相关阅读:
    spring的了解以及简单框架的搭建
    动态代理
    struts2标签(转)
    使用OGNL表达式
    struts2 ValueStack
    struts2框架xml验证
    struts2 validate手动验证
    struts2自定义拦截器
    struts2文件上传
    当findById(Integer id)变成String类型
  • 原文地址:https://www.cnblogs.com/littlewu/p/7218871.html
Copyright © 2011-2022 走看看