Svein,
this is amazingly smart solution. Took me like one hour to understand what is
going on :-) I suggested window functions becausue I thought they would be most
effective in solving this. Yes there can be holes in sequence in my data,but
thank you for your time and proposing this solution!
I think I've found ellegant and simple solution. However, I am afraid it might
be very slow for large amount of data :(
Test data with holes in sequence:
INSERT INTO MYTABLE (ID, DATE_TIME, TYPE) VALUES ('1', '01.01.2015,
00:00:00.000', 'A');
INSERT INTO MYTABLE (ID, DATE_TIME, TYPE) VALUES
I've posted my solution but I did not appear so I am reposting it.
I found simple solution.
The test data:
INSERT INTO MYTABLE (ID, DATE_TIME, TYPE) VALUES ('1', '01.01.2015,
00:00:00.000', 'A');
INSERT INTO MYTABLE (ID, DATE_TIME, TYPE) VALUES ('5', '01.01.2015,
00:01:00.000', 'A');
INSERT
By what logic do you arrive at this result?
I don't know if I can explain it any better. I want to find clusters of A,
B, C and so on, group them into one row, get the starting date from first
found row and ending date from the last found row in cluster.
Svein, if you could be so kind and show me solution which includes holes in
sequence that would be great. Once again, thank you :)