你指的是多行转多行么?如果是的话,那你需要的应该是Table Aggregate Function[1],但是这个只能在Table Api里使用,
在SQL里面没有这种语义可以直接使用。

[1]
https://ci.apache.org/projects/flink/flink-docs-master/dev/table/functions/udfs.html#table-aggregation-functions

王双利 <[email protected]> 于2020年4月26日周日 下午6:14写道:

>    看到的例子,都是 对单行数据进行转行的,这种多行数据的,有相关例子吗?
>
> 发件人: Benchao Li
> 发送时间: 2020-04-26 17:31
> 收件人: user-zh
> 主题: Re: sql 行转列
> Hi 双利,
>
> 在Flink里面行转列用的是Table Function,你可以参考下[1] 里面的 ”Join with Table Function
> (UDTF)“ 部分。
>
> [1]
>
> https://ci.apache.org/projects/flink/flink-docs-master/dev/table/sql/queries.html#joins
>
> 王双利 <[email protected]> 于2020年4月26日周日 下午5:19写道:
>
> > select ip,
> > case status when 'success' THEN sum(t) ELSE 0 end successct,
> > case status when 'fail' THEN sum(t) ELSE 0 end failct
> > from view1
> > group by ip 这样不能行转列,有解决方案吗?
> >
> >
> >
>
> --
>
> Benchao Li
> School of Electronics Engineering and Computer Science, Peking University
> Tel:+86-15650713730
> Email: [email protected]; [email protected]
>


-- 

Benchao Li
School of Electronics Engineering and Computer Science, Peking University
Tel:+86-15650713730
Email: [email protected]; [email protected]

回复