Reputation: 1816
how can i translate the following sqlite query to core data
select name, firstname, class, telephone, entryDateTime, counselor, count()
from myTable
group by strftime('yy-mm-dd', entryDateTime), name, class, counselor
order by entryDateTime desc;
i want to group by date(yy-mm-dd), class, counselor, and name. entryDateTime is in UTC but it should be converted to local time.
thanks in advance
Upvotes: 0
Views: 379
Reputation: 80265
The most flexible method for "group by"-like queries is the NSFetchedResultsController
. Please see my answer of a couple of days ago, which should help you.
To solve the problem of subgrouping based on more than one attribute, you just use the sectionNameKeyPath
as a subgroup and do the other grouping from there after fetching.
Alternatively, consider putting the attributes you need into a different entity and group by that entity.
Upvotes: 1