Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Special Report SQL Query

781721Apr 25 2011 — edited Apr 26 2011
Hi there

I have a log table looking like:
ACTION     DATE_TIME     
1          31.03.2011   (Don't count because last month)
1          01.04.2011   (Count as new)
2          01.04.2011   (Count as new)
1          04.04.2011   (Count as new because there are at least 2 days since last new ACTION=1) 
1          05.04.2011   (Don't count because since last new ACTION=1 there are not 2 days in between)
2          07.04.2011   (Count as new because there are at least 2 days since last new ACTION=2)
2          08.04.2011   (Don't count because since last new ACTION=2 there are not 2 days in between)
2          10.04.2011   (Count as new because there are at least 2 days since last new ACTION=2)
I need to count the number of ACTIONs within one calendar month (April 2011 in the example above).
The difficulty is that I only have to count them as new action when there are at least 2 days between the first counted action and the next one.

So in the case of the example above I'd need to get as result:
NEW_ACTION  COUNT
1           2
2           3
Thanks,
Peter
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 24 2011
Added on Apr 25 2011
3 comments
388 views