SELECT * FROM udaggregation ( on (select 1 as pa, 2 as pa2, tab1.* from tab1) local order by pa ASC NULLS FIRST, pa2 DESC NULLS LAST using SUM_AGG('A', 'B') AVG_AGG('C') ) AS D; SELECT * FROM udaggregation ( on (select 1 as pa, tab1.* from tab1) partition by pa using SUM_AGG('A', 'B') AVG_AGG('C') ) AS D;