简体   繁体   中英

I want to select data from last 3 days partition in oracle

In Oracle SQL, It is possible to get data from 3 days partitions only. For example, If I run SQL on 15-Aug-2019, My SQL should only look on 13,14,15 Day partitions or If I run SQL on 16-Aug-2019, My SQL should only look on 14,15,16 Day partitions.

TIA

I think that you are just looking for the following where clause:

where my_date_col >= trunc(sysdate) - 2 and my_date_col < trunc(sysdate) + 1

Where date_col is the column that holds the date that you want to filter.

For current sysdate December 30th at 10h22, trunc(sysdate) gives you December 30th at midnight, and trunc(sysdate) - 2 produces December 28th at midnight.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM