12groupby.mql 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. -- ============================================================
  2. -- Group By 聚合测试
  3. -- ============================================================
  4. -- 1. 基本 group by + count
  5. select a_category, count(*) from /test/aaa/test_aggr group by a_category
  6. /**
  7. output()
  8. **/
  9. ;
  10. -- 2. group by + sum
  11. select a_category, sum(a_amount) from /test/aaa/test_aggr group by a_category
  12. /**
  13. output()
  14. **/
  15. ;
  16. -- 3. group by + avg
  17. select a_category, avg(a_int) from /test/aaa/test_aggr group by a_category
  18. /**
  19. output()
  20. **/
  21. ;
  22. -- 4. group by + min
  23. select a_category, min(a_amount) from /test/aaa/test_aggr group by a_category
  24. /**
  25. output()
  26. **/
  27. ;
  28. -- 5. group by + max
  29. select a_category, max(a_amount) from /test/aaa/test_aggr group by a_category
  30. /**
  31. output()
  32. **/
  33. ;
  34. -- 6. group by 多聚合函数
  35. select a_category, count(*), sum(a_amount), avg(a_float) from /test/aaa/test_aggr group by a_category
  36. /**
  37. output()
  38. **/
  39. ;
  40. -- 7. group by + where
  41. select a_category, count(*) from /test/aaa/test_aggr where a_int>=20 group by a_category
  42. /**
  43. output()
  44. **/
  45. ;