I have a requirement to get the start and end times in a state where val = 'Y'and col_val < 5.
I have a table called temp_vvv, like
date_time | val | col_val
03/06/2014 08:58:00 Y 4
03/06/2014 08:59:00 Y 3
03/06/2014 09:00:00 Y 1
03/06/2014 09:01:00 Y 0
03/06/2014 09:01:30 Y 0
03/06/2014 09:02:00 Y 2
03/06/2014 09:02:30 Y 5
03/06/2014 09:03:00 Y 20
03/06/2014 09:03:30 Y 50
03/06/2014 09:04:00 Y 55
03/06/2014 09:04:30 Y 60
03/06/2014 09:05:00 Y 10
03/06/2014 09:05:30 Y 4
03/06/2014 09:06:00 Y 2
03/06/2014 09:06:30 Y 0
03/06/2014 09:07:00 Y 0
03/06/2014 09:07:30 Y 1
03/06/2014 09:08:00 N 5
03/06/2014 09:08:30 N 0
I expect a result like
start_date_time | end_date_time
--------------------------------------------------
03/06/2014 08:58:00 03/06/2014 09:02:00
03/06/2014 09:05:30 03/06/2014 09:07:30
How to get this output from select query
Please help me.
EDIT
The value col_val <5 begins with '03/06/2014 08:58:00'and ends with '03/06/2014 09:02:00'. So the first entry start_date_timeis equal '03/06/2014 08:58:00'and end_date_timeequal '03/06/2014 09:02:00', etc.
How to do it?
source
share