lundi 29 juin 2015

iOS Core data: Count with conditional - SQLite (SELECT CASE WHEN ...COUNT)

I have a SQL statement like this:

SELECT CASE
      WHEN answer < 0 THEN 'incorrect'
      WHEN answer = 0 THEN 'hold'
      WHEN answer > 0 THEN 'correct'
      END AS answer,
      COUNT(*) as COUNTANSWER,
FROM ZANSWER
GROUP BY CASE
      WHEN answer < 0 THEN 'incorrect'
      WHEN answer = 0 THEN 'hold'
      WHEN answer > 0 THEN 'correct'
      END

How can I implement above SQL statement in Objective-C used CoreData? Thanks for your helps.

Aucun commentaire:

Enregistrer un commentaire