From 3f2d8cd789516e0db3ea646f64e97c53e534a47c Mon Sep 17 00:00:00 2001 From: byd-android-2017 <17773406760@189.cn> Date: Tue, 6 Sep 2022 13:23:41 +0800 Subject: [PATCH] Update aggtable.md (#995) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新版实现AGG BY TO_MAP(cls,score) as (data)返回的数据类型是内建MAP类型,因此可以用键值对的方式直接访问,简单高效。 --- .../extend/practice_guide/aggtable.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/versioned_docs/version-0.6/extend/practice_guide/aggtable.md b/docs/versioned_docs/version-0.6/extend/practice_guide/aggtable.md index 6a4d757bdc..c754d3c645 100644 --- a/docs/versioned_docs/version-0.6/extend/practice_guide/aggtable.md +++ b/docs/versioned_docs/version-0.6/extend/practice_guide/aggtable.md @@ -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 机制。