aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/aggregate/compare_by_tuple.sql
blob: efe9622f19f69393168cc80c52bbb62860fef012 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
/* syntax version 1 */
/* postgres can not */
select
    key,
    min_by(AsTuple(subkey, value), AsTuple(subkey, value)) as min,
    max_by(AsTuple(subkey, value), AsTuple(subkey, value)) as max
from (
    select
        key,
        (case when length(subkey) != 0 then subkey else null end) as subkey,
        (case when length(value) != 0 then value else null end) as value
    from plato.Input
) group by key