I want to merge 2 rows as a new row in the COUNT
result.
This is my current SQL code,
SELECT assignment_status, COUNT(*) AS amount
FROM table_jobs
GROUP BY assignment_status
Here is the current result:
What I'd like it to be is
done: 8
started: 1
pending: 3 //*merged from to_fix and to_validate
todo: 2
Appreciate every help.
2条答案
按热度按时间3npbholx1#
You need to use conditional aggregation.
Untested without any consumable sample data, however something like this:
a0x5cqrl2#
Stu's answer is probably the right one. Here are a few alternative ways to do it: