I have an odd thing to do in sql, it's got to count how many times it finds a gap between dates in the database, this is a 2003 one, not the shiny cool 2005 one :(
Imagine a table with two fields, FromDate ToDate with in that order these values:
01/01/01 - 02/01/01
02/15/01 - 03/01/01
02/20/01 - 04/01/01
What I would like to do is see whether there are no overlaps in a give date range. So say I would want to see whether there are gaps between 01/01/01 and 06/01/01 it would return a count of two because between 02/01/01 and 02/15/01 there's a 2 week gap and there's a 2 months gap between 04/01/01 and 06/01/01.
So I can see it but have no clue how to do it in plain sql,... can someone help? Also,.. without doing it in code, do you think it's possible to return the start and endate of the gaps instead?
Cheers!why did you post this in both the oracle and sql server forums? the solutions will be completely different|||well, it has to run on both.
Why did you ask me the same question on both forums, the answer is the same.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment