使用MySQL Workbench的默认世界数据库识别大多数辐条语言的代码错误

发布于 2025-02-03 05:35:06 字数 1321 浏览 2 评论 0原文

我使用世界标准数据库在MySQL中编写了一个代码,以将最常见的语言列出一个国家列表。我使用的表是世界上城市,国家和乡村语言中的标准表。然而,对于日本来说,输出在大多数情况下是令人满意的,该代码给我带来了不正确的价值(大多数座谈式的语言应该是日语(99.1%),但是我的代码给我ainu(0%)。不确定我在哪里出错了有人可以帮忙吗

use world; 
select 
country.name as country, 
city.countrycode, 
count(city.name) as cities, 
country.population, 
countrylanguage.language, 
percentage  
from 
city  
inner join 
country  on city.countrycode=country.code  
inner join 
countrylanguage  on country.code=countrylanguage.countrycode    
where countrylanguage.percentage in  
(select max(percentage)         
from countrylanguage         
group by countrycode) 
group by country.name 
order by country.population desc ;

China CHN 363 1277558000 Chinese 92.0 
India IND 341 1013662000 Hindi 39.9 
United States USA 274 278357000 English 86.2 
Indonesia IDN 85 212107000 Javanese 39.4 
Brazil BRA 250 170115000 Portuguese 97.5 
Pakistan PAK 59 156483000 Punjabi 48.2 
Russian Federation RUS 189 146934000 Russian 86.6 
Bangladesh BGD 24 129155000 Bengali 97.7 
Japan JPN 496 126714000 Ainu 0.0 
Nigeria NGA 192 111506000 Hausa 21.1 
Mexico MEX 173 98881000 Spanish 92.1 
Germany DEU 93 82164700 German 91.3 
Vietnam VNM 22 79832000 Vietnamese 86.8 
Philippines PHL 136 75967000 Pilipino 29.3

I was writing a code in mysql using the standard database of world to figure populate a list of countries along with the language most commonly spoken. The table I am using is the standard tables within world - city, country and countrylanguage. The output is satisfactory for most part, however, for Japan, the code gives me an incorrect value (most spoke language should be Japanese (99.1%), however my code gives me Ainu (0%). Not sure where I am going wrong. Can someone help?

use world; 
select 
country.name as country, 
city.countrycode, 
count(city.name) as cities, 
country.population, 
countrylanguage.language, 
percentage  
from 
city  
inner join 
country  on city.countrycode=country.code  
inner join 
countrylanguage  on country.code=countrylanguage.countrycode    
where countrylanguage.percentage in  
(select max(percentage)         
from countrylanguage         
group by countrycode) 
group by country.name 
order by country.population desc ;

This is my output -

China CHN 363 1277558000 Chinese 92.0 
India IND 341 1013662000 Hindi 39.9 
United States USA 274 278357000 English 86.2 
Indonesia IDN 85 212107000 Javanese 39.4 
Brazil BRA 250 170115000 Portuguese 97.5 
Pakistan PAK 59 156483000 Punjabi 48.2 
Russian Federation RUS 189 146934000 Russian 86.6 
Bangladesh BGD 24 129155000 Bengali 97.7 
Japan JPN 496 126714000 Ainu 0.0 
Nigeria NGA 192 111506000 Hausa 21.1 
Mexico MEX 173 98881000 Spanish 92.1 
Germany DEU 93 82164700 German 91.3 
Vietnam VNM 22 79832000 Vietnamese 86.8 
Philippines PHL 136 75967000 Pilipino 29.3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文