SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Counting occurences of ranges within anothe range
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Knud
Starting Member

2 Posts

Posted - 05/07/2012 :  04:58:09  Show Profile  Reply with Quote

Hi,

I hope you can help me out with the following problem. I have a list of ranges in my database. I need to know the maximum of overlapping ranges.

In the example below I want to know how many ranges there are within 'request range' at the same time.
The result should be 2 as 'DB range1' and 'DB range2' are the maximum number of ranges overlapping at the same time.

..................REQUEST RANGE............................
....<-------------------------------------------->.........
..DB RANGE1................................................
<----------->..............................................
.........DB RANGE2.........................................
.......<----------->.......................................
...........................................DB RANGE3.......
.........................................<----------->.....
....................DB RANGE4..............................
..................<----------->............................

I hope my question make sense and that someone can help me?.

PS. I had to replace spaces with .

khtan
In (Som, Ni, Yak)

Singapore
16769 Posts

Posted - 05/07/2012 :  05:02:50  Show Profile  Reply with Quote
How do you count as 2 ?

Range1 overlap with Range2 as 1
Range2 overlap with Range4 as 1 ?


KH
Time is always against us

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
29156 Posts

Posted - 05/07/2012 :  05:09:34  Show Profile  Visit SwePeso's Homepage  Reply with Quote
See

http://www.sqlmag.com/article/tsql3/calculating-concurrent-sessions-part-1
http://www.sqlmag.com/article/tsql3/calculating-concurrent-sessions-part-2
http://www.sqlmag.com/article/tsql3/calculating-concurrent-sessions-part-3


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Knud
Starting Member

2 Posts

Posted - 05/07/2012 :  05:15:04  Show Profile  Reply with Quote
khtan:

Because the maximum number of overlapping ranges within 'request range' is 2:

DBRange1 and DBRange2
or
DBRange2 and DBRange4

But the point is that at no time are there anymore than two ranges overlapping eachother.

SwePeso:
I have looked at your links and I am not sure I can see exactly how it applies to my specific problem.
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16769 Posts

Posted - 05/07/2012 :  05:23:33  Show Profile  Reply with Quote
quote:
Originally posted by Knud
I have looked at your links and I am not sure I can see exactly how it applies to my specific problem.



Wow. you are a fast reader. I am still on Part 1


KH
Time is always against us

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
29156 Posts

Posted - 05/07/2012 :  06:11:13  Show Profile  Visit SwePeso's Homepage  Reply with Quote
The articles are about how to calculate the maximum concurrent sessions, which is exactly your task.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000