Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Finding Repeat Records within 72 Hours

Finding Repeat Records within 72 Hours

Finding Repeat Records within 72 Hours


I am trying to find a way to write an Oracle query (11g) that finds repeat customers transaction purchases that occur within 72 hours of each other. Specifically, if a customer does a transaction on Day 1, and then again on Day 2, I would like to have a query that will pull the transaction record from Day 2.

My table DAILYTABLE captures records for transactions by customers and has timestamps for the transaction completion time (DISCHARGE_TS). I would like to look for repeat customer transactions by EITHER a) CUSTOMER NUMBER or b) CUSTOMER NAME and DOB (sometimes a customer will register again but have an existing customer already and will receive another number, so if we pull by customer name and DOB we will get the repeat transaction), but only if there is a repeat transaction within 72 hours of the DISCHARGE_TS.

Can anyone please help a poor newbie figure this one out?

Many thanks in advance!


RE: Finding Repeat Records within 72 Hours

This might give you a start:

SQL> select * from tom;

---------- ---------
1 01-JAN-15
1 02-JAN-15
1 03-JAN-15
1 07-JAN-15
1 08-JAN-15
1 15-JAN-15
1 17-JAN-15
1 19-JAN-15
1 20-JAN-15

9 rows selected.

COUNT(*) over (partition by cust order by dte range BETWEEN CURRENT row AND interval '3' day following ) cnt,
MAX(dte) over (partition by cust order by dte range BETWEEN CURRENT row AND interval '3' day following ) maxdte
FROM tom

---------- --------- ---------- ---------
1 01-JAN-15 3 03-JAN-15
1 02-JAN-15 2 03-JAN-15
1 03-JAN-15 1 03-JAN-15
1 07-JAN-15 2 08-JAN-15
1 08-JAN-15 1 08-JAN-15
1 15-JAN-15 2 17-JAN-15
1 17-JAN-15 3 20-JAN-15
1 19-JAN-15 2 20-JAN-15
1 20-JAN-15 1 20-JAN-15

9 rows selected.

In order to understand recursion, you must first understand recursion.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close