简体   繁体   中英

PL/SQL : How to extract data for any 5 days in a month

I am trying to extract data from any 5 days of a month."Not" the last 5 days or the next 5 days.

I basically have to find those customers who perform any action in "ANY" 5 days of a month.

Would appreciate any help on this.

Your question is rather poorly written, because it provides little information about the table structures, attempts you have made, or even the database tag of your system. Because you are new to StackOverflow, I'll make some assumptions and attempt to answer it.

Assuming you have a table of actions and a specific month in mind, you can do this relatively easily. The Oracle syntax looks something like this:

select customerId
from actions a
where ActionDateTime >= '2014-01-01' and ActionDateTime < '2014-02-01'
group by customerId
having count(distinct trunc(ActionDateTime)) >= 5;

Of course, you will have to adapt this for your environment.

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