median.sql 574 B

123456789101112131415161718
  1. /* syntax version 1 */
  2. /* postgres can not */
  3. $t = AsList(AsStruct(1 as a),AsStruct(2 as a));
  4. $f = AGGREGATION_FACTORY("median");
  5. select Yql::Aggregate($t, AsTuple(), AsTuple(AsTuple(AsAtom("res"), $f(
  6. ListItemType(TypeOf($t)), ($z)->{return $z.a}))));
  7. $f = AGGREGATION_FACTORY("percentile", 0.9);
  8. select Yql::Aggregate($t, AsTuple(), AsTuple(AsTuple(AsAtom("res"), $f(
  9. ListItemType(TypeOf($t)), ($z)->{return $z.a}))));
  10. use plato;
  11. insert into @a select * from as_table($t);
  12. commit;
  13. select AGGREGATE_BY(a,$f) from @a;
  14. select AGGREGATE_BY(distinct a,$f) from @a;