Using aggregate functions in a Core Data Fetch Request
Using aggregate functions in a Core Data Fetch Request
- Subject: Using aggregate functions in a Core Data Fetch Request
- From: Fred McCann <email@hidden>
- Date: Fri, 26 Sep 2008 15:25:16 -0400
I'm attempting to find an object that has a maximum value in the data
store. In sql, the query would be something like this:
select * from foo where value = select max(value) from foo.
Actually, I would be thrilled if I could just get select max(value)
from foo.
I've read through the Core Data and Predicates pdfs, and there is a
mention of a "max" function in the "BNF Definition of Cocoa
Predicates" of the Predicates document, but I've had no luck. My
current attempt is to create a fetch request in the XCode Data Modeler
using the predicate:
id == max:(
id
)
When I try to execute this, I get this error:
Unable to generate SQL for predicate (id == max:(
$FETCHED_PROPERTY.id
)) (problem on RHS)
I'm currently using Sqlite as the backing store.
Does anyone have any suggestions on how to do this? Is this even
possible? What I'm trying to accomplish is to maintain ids across
multiple persistent stores that can weakly linked as fetched properties.
- Fred McCann
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden