dimanche 3 avril 2016

How to sum two fields using CASE WHEN in SQLite on Android

I want to display the sum of field tries and the sum of points concatenated together but I get the sum only of the field tries.

SELECT
ContactName,
SUM(CASE WHEN event = 'Event1' THEN tries || '/' || points END) AS "E1",
SUM(CASE WHEN event = 'Event2' THEN tries || '/' || points END) AS "E2",
SUM(CASE WHEN event = 'Event3' THEN tries || '/' || points END) AS "E3",

FROM names
WHERE
period = 2
GROUP BY
ContactName

Aucun commentaire:

Enregistrer un commentaire