• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using aggregate functions in a Core Data Fetch Request
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Using aggregate functions in a Core Data Fetch Request
      • From: Jamie Hardt <email@hidden>
  • Prev by Date: Changing slide back destination during drag
  • Next by Date: Re: NSNotificationCenter
  • Previous by thread: Changing slide back destination during drag
  • Next by thread: Re: Using aggregate functions in a Core Data Fetch Request
  • Index(es):
    • Date
    • Thread