We help IT Professionals succeed at work.
Get Started

A complex Oracle PL/SQL query

Last Modified: 2012-08-24
I have data as follows:

ColKey           ColStartDt                                ColEnd Dt
1                  01-JAN-2012                   03-JAN-2012 11:59:59 PM
2                  04-JAN-2012                   06-JAN-2012 11:59:59 PM
3                  07-JAN-2012                   09-JAN-2012 11:59:59 PM
3                  06-JAN-2012                   11-JAN-2012 11:59:59 PM
4                  12-JAN-2012                   14-JAN-2012 11:59:59 PM
4                  14-JAN-2012                   17-JAN-2012 11:59:59 PM
5                  18-JAN-2012                   20-JAN-2012 11:59:59 PM

As you can see, some ColKey values fall in multiple date ranges. I need to have an output such as:

ColKey, count(*)
1             1
2             1
3             2
4             2
5             1

I am trying to come up with the query but any help would be appreciated.
Watch Question
Information Technology Specialist
This problem has been solved!
Unlock 1 Answer and 27 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE