| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- -- ============================================================
- -- Group By 聚合测试
- -- ============================================================
- -- 1. 基本 group by + count
- select a_category, count(*) from /test/aaa/test_aggr group by a_category
- /**
- output()
- **/
- ;
- -- 2. group by + sum
- select a_category, sum(a_amount) from /test/aaa/test_aggr group by a_category
- /**
- output()
- **/
- ;
- -- 3. group by + avg
- select a_category, avg(a_int) from /test/aaa/test_aggr group by a_category
- /**
- output()
- **/
- ;
- -- 4. group by + min
- select a_category, min(a_amount) from /test/aaa/test_aggr group by a_category
- /**
- output()
- **/
- ;
- -- 5. group by + max
- select a_category, max(a_amount) from /test/aaa/test_aggr group by a_category
- /**
- output()
- **/
- ;
- -- 6. group by 多聚合函数
- select a_category, count(*), sum(a_amount), avg(a_float) from /test/aaa/test_aggr group by a_category
- /**
- output()
- **/
- ;
- -- 7. group by + where
- select a_category, count(*) from /test/aaa/test_aggr where a_int>=20 group by a_category
- /**
- output()
- **/
- ;
|