Dear All
I have following table
id|name|female
1|John|No
2|Brian|No
3|Tanya|Yes
How can I get percentage of females in this table?
Thanks a lot!
SviridSELECT Sum(CASE WHEN 'Yes' = female THEN 1e0 END) / Count(*)
FROM myTable-PatP|||This should be faster on big number of records:
select FemalesPercentage = 100.0 * sum(case when female = 'Yes' then NumberOf else 0.0 end) / sum(NumberOf)
from (select female,
NumberOf = count(1)
from SviridsTable
group by female) as x
Showing posts with label tablethanks. Show all posts
Showing posts with label tablethanks. Show all posts
Monday, March 19, 2012
Subscribe to:
Posts (Atom)