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;
我目前正在尝试获取百分比但出现错误,我认为语法看起来正确吗?请帮忙!
'Percentage'
是一个字符串文字。对象(列)名称用双引号括起来。
所以你需要使用"Percentage"
not'Percentage'
尝试使用这个
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;