Опитайте с този:
SELECT
ID,
`time` AS time1,
(SELECT MIN(st.`time`) FROM T1 st WHERE st.ID = T1.ID AND st.`time` > T1.`time`) AS time2
FROM T1
Опитайте с този:
SELECT
ID,
`time` AS time1,
(SELECT MIN(st.`time`) FROM T1 st WHERE st.ID = T1.ID AND st.`time` > T1.`time`) AS time2
FROM T1