13having.mql 839 B

12345678910111213141516171819202122232425262728293031323334353637
  1. -- ============================================================
  2. -- Having 子句测试
  3. -- ============================================================
  4. -- 1. group by + having count
  5. select a_category, count(*) from /test/aaa/test_aggr group by a_category having count(*)>2
  6. /**
  7. output()
  8. match("category_a")
  9. **/
  10. ;
  11. -- 2. group by + having sum
  12. select a_category, sum(a_amount) from /test/aaa/test_aggr group by a_category having sum(a_amount)>500
  13. /**
  14. output()
  15. match("category_c")
  16. match("category_b")
  17. **/
  18. ;
  19. -- 3. group by + having avg
  20. select a_category, avg(a_int) from /test/aaa/test_aggr group by a_category having avg(a_int)>=30
  21. /**
  22. output()
  23. match("category_b")
  24. match("category_c")
  25. **/
  26. ;
  27. -- 4. having 无匹配结果
  28. select a_category, count(*) from /test/aaa/test_aggr group by a_category having count(*)>100
  29. /**
  30. output()
  31. count(0)
  32. **/
  33. ;