aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/window/generic/session_aliases.sql
blob: 2375d560646f8a774ec0b5b12e8fc386562049bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* syntax version 1 */
/* postgres can not */

SELECT
    user,
    ts,
    SessionStart() over w1 as ss1,
    SessionStart() over w as ss,
    
    AGGREGATE_LIST(ts) over w as ts_session,
    COUNT(1) over w as session_len,
FROM plato.Input
WINDOW w AS (
    PARTITION BY user, SessionWindow(ts, 10) as ss0
    ORDER BY ts
    ROWS BETWEEN 10 PRECEDING AND 10 FOLLOWING
),
w1 AS (
    PARTITION BY SessionWindow(ts, 10), user
    ORDER BY ts
    ROWS BETWEEN 100 PRECEDING AND 100 FOLLOWING
)
ORDER BY user, ts;