Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to Group discontinued time periods

$
0
0

Hi All:

I have an issue which costs me bunch of time to develop. Basically I am trying to use discounted time in a select query but feel  like get nowhere to start.

the scenarios is like this:

I have many rows of data of this and I would like to have a solution I can select time period from just like what I can do for integer and text:

Select *

From Table

Where Group = B

and Open_Date in (select the all group A's time interval)

----------------------------------

to explain this problem in plain text, I would like to select all records from Group B whose Open_Date is within the interval between Group A's Open_Date and Close_Date. Thanks all in advance.

Record Open_Date Close_Date GROUP
1 9/12/2013 9:25 9/12/2013 10:44 A
2 9/12/2013 10:19 9/12/2013 10:39 A
3 9/12/2013 10:22 9/12/2013 10:22 A
4 9/12/2013 10:56 9/12/2013 12:41 B
5 9/12/2013 12:00 9/12/2013 12:00 B
6 9/12/2013 12:00 9/12/2013 12:01 A
7 A+E301:H318 9/12/2013 12:03 A
8 9/12/2013 13:44 9/12/2013 13:46 C
9 9/12/2013 13:46 9/12/2013 13:46 C
10 9/12/2013 13:46 9/12/2013 14:33 C
11 9/12/2013 14:04 9/12/2013 14:09 A
12 9/12/2013 14:23 9/12/2013 17:05 A
13 9/12/2013 15:54 9/12/2013 15:54 A
14 9/12/2013 15:54 9/12/2013 15:55 B
15 9/12/2013 15:55 9/12/2013 15:55 B
16 9/12/2013 15:55 9/12/2013 15:58 A
17 9/12/2013 16:02 9/12/2013 16:02 A

 


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>