13having.mql 739 B

1234567891011121314151617181920212223242526272829303132
  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. **/
  9. ;
  10. -- 2. group by + having sum
  11. select a_category, sum(a_amount) from /test/aaa/test_aggr group by a_category having sum(a_amount)>500
  12. /**
  13. output()
  14. **/
  15. ;
  16. -- 3. group by + having avg
  17. select a_category, avg(a_int) from /test/aaa/test_aggr group by a_category having avg(a_int)>=30
  18. /**
  19. output()
  20. **/
  21. ;
  22. -- 4. having 无匹配结果
  23. select a_category, count(*) from /test/aaa/test_aggr group by a_category having count(*)>100
  24. /**
  25. output()
  26. count(0)
  27. **/
  28. ;