Unverified Commit 3f2d8cd7 authored by byd-android-2017's avatar byd-android-2017 Committed by GitHub

Update aggtable.md (#995)

新版实现AGG BY TO_MAP(cls,score) as (data)返回的数据类型是内建MAP类型,因此可以用键值对的方式直接访问,简单高效。
parent a2b9e503
......@@ -341,14 +341,17 @@ FROM score
GROUP BY sid
AGG BY TO_MAP(cls,score) as (data);
insert into studentscore
select
a.sid,a.name,
cast(GET_KEY(b.data,'chinese','0') as int),
cast(GET_KEY(b.data,'math','0') as int),
cast(GET_KEY(b.data,'english','0') as int)
from student a
left join aggscore2 b on a.sid=b.sid
insert into
studentscore
select
a.sid,
a.name,
b.data['chinese'] ,
b.data['math'],
b.data['english']
from
student a
left join aggscore2 b on a.sid = b.sid;
```
​ 本实例通过表值聚合将分组后的多行转单列然后通过 GET_KEY 取值的思路来实现。同时,也使用了 Fragment 机制。
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment