So, for this particular scenario, you can use “SUM” with the conditional statement instead of countif.
So, below are commands/queries for doing that.
SELECT UID,
COUNT(UID) AS TotalRecords,
SUM(ContractDollars) AS ContractDollars,
(SUM(CASE WHEN MyColumn = 1 THEN 1 ELSE 0 END) * 100.0 / COUNT(UID)) AS PercentageRecords
FROM dbo.AD_CurrentView
GROUP BY UID
HAVING SUM(ContractDollars) >= 500000;
So, in these commands, “ SUM(CASE WHEN MyCloumn = 1 THEN 1 ELSE 0 END) “ is finding out by counting only rows.
Multiplying with 100.0 ensures that the result is in percentage with decimal points.
And “COUNT” tells us the number of rows that meet the condition in the question.