Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6075315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:28:51+00:00 2026-05-23T10:28:51+00:00

Sorry if title does not make any sense. Let me explain it a bit

  • 0

Sorry if title does not make any sense.

Let me explain it a bit further.

I have this CoreData application and I am relatively new in CoreData. I have two tables. One is Budget and one is Spending. So Budget table has a field called TotalBudget. Now I have different rows in Spending Table which user input over the time and this table has a field called Individual Spend.

Now what I am hoping to do is to get only those budgets where Sum of Individual Spend is less than TotalBudget (Budget table). In SQL language it would be something like below

Select BudgetName
From Budget
Where TotalBudget < (Select Sum(IndividualBudget) From Spend Where BudgetID = Budget.BudgetID)

How can I achieve that in core data? I have the code to retrieve data from one table and I can use NSPredicate to filter records based to BudgetStartDate and BudgetEndDate but how can I achieve something like that.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:28:51+00:00Added an answer on May 23, 2026 at 10:28 am

    Assuming following object model:

    Budget
    --amount (decimal)
    --spend (relationship to IndividualSpend object)
    
    IndividualSpend
    --amount (decimal)
    

    This will get you an array of Budget entities where the spend amount is > budget amount:

    NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
    fetch.entity = [managedObjectModel objectForKey:@"Budget"];
    fetch.predicate = [NSPredicate predicateWithFormat:@"spend.@sum.amount > amount"];
    
    NSError *error = nil;
    NSArray *results = [context executeFetchRequest:fr error:&error];
    if (error) {
      NSLog(@"ERROR: %@", error);
    }
    NSLog(@"Results: %@", results);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if the title doesn't make sense. Basically I have a series of strings
Sorry i could not find a proper title to this question. I have generated
Sorry the title is not very clear. This is a follow up to my
Sorry for long winded title, this makes a lot more sense with an example.
sorry about the title, I'm not sure how to even describe this, which makes
I'm sorry about the title I'm just not sure how to describe this one.
Firstly, i am sorry if the title does not properly describe my problem, but
Sorry if my question does not match the title, but i think it does:
Sorry for the complicated title. I have something like this: class Base { public:
Sorry the title isn't more help. I have a database of media-file URLs that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.