| 12345678910111213141516171819202122232425262728293031323334353637 |
- -- ============================================================
- -- Having 子句测试
- -- ============================================================
- -- 1. group by + having count
- select a_category, count(*) from /test/aaa/test_aggr group by a_category having count(*)>2
- /**
- output()
- match("category_a")
- **/
- ;
- -- 2. group by + having sum
- select a_category, sum(a_amount) from /test/aaa/test_aggr group by a_category having sum(a_amount)>500
- /**
- output()
- match("category_c")
- match("category_b")
- **/
- ;
- -- 3. group by + having avg
- select a_category, avg(a_int) from /test/aaa/test_aggr group by a_category having avg(a_int)>=30
- /**
- output()
- match("category_b")
- match("category_c")
- **/
- ;
- -- 4. having 无匹配结果
- select a_category, count(*) from /test/aaa/test_aggr group by a_category having count(*)>100
- /**
- output()
- count(0)
- **/
- ;
|