目标 C:CoreData 和聚合
给定一个具有日期(天)和称为交易金额的 CoreData-Entity。 CoreData是否可以(以及如何)按日期聚合/分组“表”(包含所有交易)并计算第二列/属性中的当天总和? (SQL 解决方案将是SELECT date, sum(ammount) FROM transaction GROUP BY date
)
Given a CoreData-Entity with an date (days) and an ammount called Transaction.
Is it with CoreData possible (and how) to aggregate/group the 'table' (with all Transactions) by Date and calculate the sum of the day in a second column/attribute?
(the SQL-Solution would be SELECT date, sum(ammount) FROM transaction GROUP BY date
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它们可能并不完全符合您的要求,但由于 Core Data 完全符合 KVC 标准,请查看 键值编码集和数组运算符。这至少应该让您非常接近您想要做的事情。
They may not do exactly what you want, but since Core Data is fully KVC compliant, take a look at the Key-Value Coding Set and Array operators. This should at least get you pretty close to what you're looking to do.
Stack Overflow:“CoreData 相当于 sum…group by”
Stack Overflow: "CoreData equivalent of sum…group by"