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;
我目前正在尝试获取百分比,但收到错误,语法看起来正确我认为? 请帮忙!
答案 0 :(得分:3)
'Percentage'
是一个字符串文字。对象(列)名称用双引号括起来。
因此,您需要使用"Percentage"
而不是'Percentage'
答案 1 :(得分:1)
尝试使用此
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;