1 2 3 4 5 6 7 8 9
USE plato; SELECT a, lag(a) over w as prev_a, min(a) over w as min_a FROM Input WINDOW w AS (PARTITION BY b ORDER by c) ORDER BY a;