count_if.sql 408 B

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