troubleshooting Question

Oracle SQL: Difference between dateA, row1 and dateA, row2

Avatar of GNOVAK
GNOVAKFlag for United States of America asked on
Oracle DatabaseSQL
5 Comments1 Solution692 ViewsLast Modified:
I have a table in Oracle 11g that has the following:

Product           TYPE_CODE          Date_A
1                            01                  01/01/08
1                            04                  01/02/08
1                            01                  03/01/08
1                            06                  03/15/08
1                            01                  03/15/08
2                            01                  01/01/08
2                            04                  01/05/08
2                            01                  02/14/08

Using SQL, I would like to determine for each product  the average, min and max number of days between the first date and the second date, second and third, third and fourth, etc. for the 01 Types.

So in the above example,
For prodcut 1, I would find the difference between 03/01/08 and 01/01/08. Then compare this to the difference between 03/01/08 and 03/15/08.  
The number of rows with 01 types and dates for any given product will vary - some could have 1, some 10, some 4, etc.

Can this be accomplished in SQL?
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros