aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/aggregate/group_by_gs_subselect.sql
blob: 8b28224ab56a90777a6478bd0961f2e5c3567e15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* syntax version 1 */
/* postgres can not */
USE plato;

$sub = (SELECT
  Sum(Cast(subkey as Uint32)) as sumLen,
  key,
  value,
  Grouping(key, value) as grouping
FROM Input
GROUP BY GROUPING SETS ((key),(value))
);

--INSERT INTO Output
SELECT t.sumLen, t.key, t.value, t.grouping FROM $sub as t
ORDER BY t.key, t.value