yql-7888_mapfieldsubset.sql 862 B

123456789101112131415161718192021222324252627
  1. /* postgres can not */
  2. /* syntax version 1 */
  3. use plato;
  4. define subquery $input() as
  5. select
  6. value,
  7. WeakField(strongest_id, "String") as strongest_id,
  8. WeakField(video_position_sec, "String") as video_position_sec,
  9. key,
  10. subkey
  11. from concat(Input, Input)
  12. where key in ("heartbeat", "show", "click")
  13. and subkey in ("native", "gif");
  14. end define;
  15. -- Native:
  16. define subquery $native_show_and_clicks($input) as
  17. select
  18. value, strongest_id, key
  19. from $input()
  20. where subkey == "native"
  21. and key in ("click", "show");
  22. end define;
  23. select count(distinct strongest_id) as native_users from $native_show_and_clicks($input);
  24. select count(distinct strongest_id) as native_users_with_click from $native_show_and_clicks($input) where key == "click";