Follow is sample table
Project | Reporter | Fixer | Status
--------+----------+--------+--------
P1 | Fernando | Janith | closed
P1 | hasitha | Nimna | Fixed
p1 | Amal | Nimna | Fixed
P2 | Nimal | Amal | Fixed
P3 | Kamal | Nimal | Fixed
P4 | Andrew | Amal | Fixed
What I want is Project name, Status count for each project, count of each project's Status 'Fixed', count of project's Status 'Closed' and Fixer who fixed most number of Projects.
except the Bold part I was able to get others using following query
SELECT Project
,count(Project) AS ProjectCount
,count(CASE STATUS
WHEN 'Fixed'
THEN 1
ELSE NULL
END) AS Fixed
,count(CASE STATUS
WHEN 'Closed'
THEN 1
ELSE NULL
END) AS Closed
FROM TABLE
GROUP BY Project;
Output I need
Project, ProjectCount, Fixed, Closed, Fixcer
P1, 3, 2, 1, Nimna