[英]Core data fetch request with GROUP BY
I have a table in my application which consists of some names and phone numbers and orderIDs and dates (4 columns). 我的应用程序中有一个表,其中包含一些名称,电话号码,orderID和日期(4列)。 I want to get an array of all distinct phone numbers (Note that someone with a phone number may have several orderIDs). 我想获取所有不同电话号码的数组(请注意,拥有电话号码的人可能具有多个orderID)。
Test case: suppose that this is the current records of my table. 测试用例:假设这是我表的当前记录。
Name phoneNumber orderID date John 1234 101 2014-12-12 Susan 9876 102 2014-12-08 John 1234 103 2014-12-17
I want an array of distinct phone numbers only, something like: {1234, 9876} How can I perform such a fetch in core data? 我只需要一组不同的电话号码,例如:{1234,9876}如何在核心数据中执行这种提取?
Any help would be much appreciated. 任何帮助将非常感激。 Thank you. 谢谢。
PS: As I knew in SQL I could do something like: PS:正如我在SQL中所知道的,我可以做类似的事情:
SELECT phoneNumber FROM orders GROUP BY phoneNumber
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.