Du kan använda CASE
i du väljer klausul.
SELECT name,
SUM(CASE WHEN type = 'red' THEN "count" ELSE 0 END) numred,
SUM(CASE WHEN type = 'blue' THEN "count" ELSE 0 END) numblue
FROM tableName
GROUP BY name
Du kan använda CASE
i du väljer klausul.
SELECT name,
SUM(CASE WHEN type = 'red' THEN "count" ELSE 0 END) numred,
SUM(CASE WHEN type = 'blue' THEN "count" ELSE 0 END) numblue
FROM tableName
GROUP BY name