I have the following table:
SELECT * FROM mytable ORDER BY id; id name code time 1 A 111 1 2 A 111 2 3 A 888 3 4 A 888 4 5 A 888 5 6 A 888 6 7 A 888 7 8 A 111 8 9 A 111 9 10 A 111 10 I need to get a result like this:
name code times_between A 111 1,2 A 888 3,7 A 111 8,10 Is it possible to group by "chunks"? I need to make a distinction based on time, so I can't just group by name,code and get the first and last element only.
ORDER BYin your queries explicitly.