CoreData等价于sum ... group by [英] CoreData equivalent of sum...group by
本文介绍了CoreData等价于sum ... group by的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下伪SQL模式:
I have the following pseudo-SQL schema:
table flight
id int primary key
date timestamp
aircraft_id int (foreign key to aircraft.id)
table flight_component
flight_id int (foreign key to flight.id)
component_id int (foreign key to component.id)
duration double
如果我将它转换为使用CoreData,等效的方式来获得每个组件的总持续时间与另一个查询谓词?我认为SQL等效项将是
If I convert this to using CoreData, is there an equivalent way to get the total duration for each component with another query predicate? I think the SQL equivalent would be
select component_id, sum(duration)
from flight_component
join flight on (flight_component.flight_id = flight.id)
where flight.date between ? and ?
group by component_id
或者我必须进行查询,然后总结所有组件自己?
Or am I going to have to make my query and then sum up all the components myself?
推荐答案
可以查询@someArray。在 Collection Operators page。
You can query for @"someArray.@sum". There's a list of such operators on the Collection Operators page.
这篇关于CoreData等价于sum ... group by的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文