0

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;

what did i try?

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

4

1 回答 1

1

类似“group by”的查询最灵活的方法是NSFetchedResultsController. 请参阅我几天前的回答,这应该对您有所帮助。

要解决基于多个属性的子分组问题,您只需将sectionNameKeyPath用作子组并在获取后从那里进行另一个分组。

或者,考虑将您需要的属性放入不同的实体并按该实体分组。

于 2013-06-05T21:46:30.113 回答