I have used this query but it gives me percentage of only single project.
x
SELECT
100.0 * COUNT(CASE WHEN Proj = 'abc' AND ID = '101' THEN Update END) /
COUNT(CASE WHEN ID = '101' THEN proj END) AS percentage
FROM Updates;
Advertisement
Answer
It is a little unclear what you want. If you want the proportion within a project:
SELECT Proj,
AVG(CASE WHEN ID = '101' THEN 100.0 ELSE 0 END) as percentage
FROM Updates
GROUP BY Proj;
If you want the proportion over all projects:
SELECT Proj,
COUNT(*) * 100.0 / SUM(COUNT(*)) OVER () as percentage
FROM Updates
WHERE ID = 101
GROUP BY Proj;