yql-14277.sql 473 B

123456789101112131415161718192021
  1. /* syntax version 1 */
  2. $data = [
  3. <|id:1, time:1, value:'a'|>,
  4. <|id:1, time:2, value:null|>,
  5. <|id:1, time:3, value:null|>,
  6. <|id:1, time:4, value:'b'|>,
  7. <|id:1, time:5, value:null|>,
  8. <|id:2, time:1, value:'c'|>,
  9. <|id:2, time:2, value:'d'|>,
  10. <|id:2, time:3, value:null|>,
  11. ];
  12. select
  13. a.*,
  14. count(value) over w1 as w1,
  15. max(value) over w2 as w2,
  16. from
  17. as_table($data) as a
  18. window w1 as (order by time, id),
  19. w2 as (partition by id)
  20. order by id, time;