Oracle取當前日期的最近工作日

來源:互聯網
上載者:User

標籤:order by   tab   當前日期   acl   需求   描述   rom   ble   order   

  描述:現有一需求,日期表中存放了日期和是否節假日(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

Oracle取當前日期的最近工作日

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.