find Percentage

Database
N/A

find Percentage

How do I find percentage

This is not working

Can anyone suggest?

SELECT DISTINCT a.apple, (CAST((Count(a.apple))/ (SELECT count(a.apple) from a) *100 AS DECIMAL (15,2) )) AS percentage

FROM a

GROUP BY a.apple;

1 REPLY
Senior Apprentice

Re: find Percentage

select
apple, 100 * count(*) / sum(count(*)) over ()
from a
group by apple