Skip to content

Commit

Permalink
Update aggtable.md (#995)
Browse files Browse the repository at this point in the history
新版实现AGG BY TO_MAP(cls,score) as (data)返回的数据类型是内建MAP类型,因此可以用键值对的方式直接访问,简单高效。
  • Loading branch information
byd-android-2017 authored Sep 6, 2022
1 parent a2b9e50 commit 3f2d8cd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions docs/versioned_docs/version-0.6/extend/practice_guide/aggtable.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 机制。
Expand Down

0 comments on commit 3f2d8cd

Please sign in to comment.