multi.sql 989 B

12345678910111213141516171819202122
  1. /* syntax version 1 */
  2. /* postgres can not */
  3. USE plato;
  4. $input = (select AsStruct(
  5. key as key,
  6. Just(subkey) as subkey,
  7. Just(value) as value) as nums from Input);
  8. SELECT
  9. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("count")) as count,
  10. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("min")) as min,
  11. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("max")) as max,
  12. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("sum")) as sum,
  13. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("avg")) as avg,
  14. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("stddev")) as stddev,
  15. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("percentile", 0.5)) as p50,
  16. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("aggregate_list")) as agg_list,
  17. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("aggregate_list_distinct")) as agg_list_distinct,
  18. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("mode")) as mode,
  19. MULTI_AGGREGATE_BY(nums, AGGREGATION_FACTORY("top", 3)) as top,
  20. FROM $input;