Reputation: 421
select
(
(select Count(country_isoname) from games.country where country_olympic_code is null)
/
(select Count(*) from games.country)
) * 100 as 'Percentage'
from
games.country;
I am currently trying to get the percentage but getting an error, syntax looks correct i think? PLease help!
Upvotes: 0
Views: 5641
Reputation: 4030
Try using this
select (t1.specific_count/t2.all_count)*100 from
(select count(country_isoname) as specific_count from country
where country_olympic_code is null) t1,
(select count(*) as all_count from country) t2;
Upvotes: 1
Reputation:
'Percentage'
is a string literal. Object (column) names have be enclosed with double quotes.
So you need to use "Percentage"
not 'Percentage'
Upvotes: 4