GROUP BY equivalent for Core Data

后端 未结 4 681
离开以前
离开以前 2020-12-31 19:06

I know that I can use @distinctUnionOfObjects to find something like the following in SQL:

SELECT a_value
FROM my_table
GROUP BY a_value;

W

4条回答
  •  情话喂你
    2020-12-31 19:17

    You can use Predicate Programming.

    EDIT: Sorry you can not use predicates for Group By at least not straight-forward. I just read on the references.

    Limitations: You cannot necessarily translate “arbitrary” SQL queries into predicates or fetch requests. There is no way, for example, to convert a SQL statement such as

    SELECT t1.name, V1, V2

    FROM table1 t1 JOIN (SELECT t2.name AS V1, count(*) AS V2
    
        FROM table2 t2 GROUP BY t2.name as V) on t1.name = V.V1
    

提交回复
热议问题