aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/window/win_group_peephole.sql
blob: 7997aa09404d8634ccb8f4496a2c09ec6bebfe5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* syntax version 1 */
/* postgres can not */


$t = SELECT 'john' as name, 42 as age;

SELECT 
    SUM(age) OVER w0 AS sumAge, 
    LEAD(age,1) OVER w1 AS nextAge,
    LAG(age,1) OVER w1 AS prevAge,
    RANK() OVER w0 as rank,
    DENSE_RANK() OVER w0 as dense_rank,
    ROW_NUMBER() OVER w1 as row_number,
FROM $t AS u
WINDOW 
    w0 AS (ORDER BY name),
    w1 AS ()
;