14distinct.mql 818 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. -- ============================================================
  2. -- count(distinct ...) 测试
  3. -- ============================================================
  4. -- 1. count(distinct 单字段)
  5. select count(distinct a_category) from /test/aaa/test_aggr
  6. /**
  7. output()
  8. match("count(distinct a_category)","3")
  9. **/
  10. ;
  11. -- 2. count(distinct 数值字段)
  12. select count(distinct a_int) from /test/aaa/test_aggr
  13. /**
  14. output()
  15. **/
  16. ;
  17. -- 3. count(distinct bool 字段)
  18. select count(distinct a_bool) from /test/aaa/test_aggr
  19. /**
  20. output()
  21. match("count(distinct a_bool)","2")
  22. **/
  23. ;
  24. -- 4. count(distinct) + where
  25. select count(distinct a_category) from /test/aaa/test_aggr where a_bool=true
  26. /**
  27. output()
  28. **/
  29. ;
  30. -- 5. count(distinct) 空结果
  31. select count(distinct a_category) from /test/aaa/test_aggr where a_int=9999
  32. /**
  33. output()
  34. **/
  35. ;