SQLite 中是否有产品运算符(或解决方法)?
我正在使用 GROUP BY
每月汇总一个项目。我想要一列的 SUM
和另一列的乘积。我在网上或在我的书中找不到产品运算符...但是是否有一系列其他运算符可以构建产品运算符?
在紧要关头,我可以在 R 中运行产品,这就是数据的方向,但我希望最大限度地减少循环量。
谢谢!
更新:好的,所以我真的想创建一个产品聚合器来将列的产品发送回 R。在尝试回答进一步的下游问题时,我得到了将所有内容组合在一起的答案。已经有一个未合并到 SQLite 中的常用函数库(希利函数)。我可以使用库(RSQLite. extfuns)。因此,我可以通过对日志总和求幂来创建产品聚合器。感谢 DWin 向我展示有关 RQLite.extfuns 的关键部分图书馆。
I am using GROUP BY
to aggregate over an item per month. I would like the SUM
of one column and the product of another. I can't find a product operator online or in my book... but is there a series of other operators that will build the product operator?
In a pinch, I can do the product operating in R, which is where the data are heading, but I would love to minimize the amount of looping I do.
Thanks!
Update: OK, so I really wanted to create a product aggregator to send the product of a column back to R. In trying to answer a futerh downstream question I got the answer that put it all together. There's already a library of common functions not incorporated into SQLite (the Healey functions). I can easily use these functions in R using a library (RSQLite.extfuns). So I can create the product aggregator by exponentiating the sum of logs. Thanks to DWin for showing me the key piece about the RQLite.extfuns library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 create_function() 添加自己的聚合运算符。
You can add your own aggregate operator using create_function().
如果每个组的行数足够小,您可以使用
group-concat
< /a> 返回 R 的所有被乘数。If the number of rows per group is small enough, you might use
group-concat
to return all the multiplicands for R.