14distinct.mql 742 B

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