简体   繁体   English

有关字符链接的分组和聚合[在SQL HANA DATABASE中]

[英]Grouping & Aggregation about Character linking[in SQL HANA DATABASE]

My data frame like this: 我的数据框是这样的:

> mydata
   time  id  product
1 201301  1   apple
2 201302  1     htc
3 201302  1   apple
4 201302  2     htc
5 201302  2   apple

How get the following result? 如何获得以下结果?

> result
   time   id   product
1 201301  1     apple
2 201302  1 apple&htc
3 201302  2 apple&htc

I have tried ddply() function like this: 我已经尝试过ddply()函数,如下所示:

ddply(mydata,.(time,id),summarise,paste0(product,"&",product))

But it doesn't work as my expectation.Thanks for your answers. 但这不符合我的预期。谢谢您的回答。

And,my point is, how to realize in SQL in SAP HANA DATABASE? 而且,我的意思是,如何在SAP HANA DATABASE中的SQL中实现? Thanks a lot! 非常感谢!

you can try this: 您可以尝试以下方法:

 ddply(tab, .(time, id), summarise, product = paste(product, collapse="&"))

hth 心连心

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM