我有以下伪SQL架构:
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等价物是
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
或者我将不得不进行查询,然后自己总结所有组件?