I need help writing SQL queries for the following questions from the following tables. Questions: How many languages are
Posted: Sun May 15, 2022 9:58 am
I need help writing SQL queries for the following questions from
the following tables.
Questions:
How many languages are there?
What's the most commonly spoken language?
Which countries speak those languages?
Which countries have the largest
population?
What's the most commonly spoken language in the country
with the largest population?
How many cities speak the most popular
language?
What's the largest populated city that speaks the most
popular language?
What's the second most popular language?
Which countries have English as their most popular
language?
Example that was given was:
SELECT continent,name FROM world x
WHERE x.name <= ALL (
SELECT name FROM world y
WHERE x.continent=y.continent)
Х MySQL Workbench х MySQL Workbench Х Local instance MySQL80 (rela.. X Local instance MySQL80 (rela.. X (rela... x tabase Server Tools Scripting Help Edit View Query Database Server Tools Scripting Help File Edit View Query Database Server Tools Scripting Help File SOL 8 SQL 9 SOL SOL 9 @NO world x- city country countrylanguage world_x city country countrylanguage x world_x city country countrylanguage SQL Additions TO Jump to SQL Additions I 1 Jump to SQL Additions I 1 Jump to Dont Limit 7 Dont Limit INT Don't Limit SELECT * FROM world.city; 1. SELECT * FROM world.countrylanguage; 1. SELECT * FROM world.country; Automatic context help i: disabled. Use the toolbar || manually get help for the current caret position or t toggle automatic help. Navigator SCHEMAS a Filter objects drinks relational_database sakila sys world Automatic context help is disabled. Use the toolbart manually get help for the current caret position or to toggle automatic help. Navigator SCHEMAS a Filter objects drinks ► relational_database sakila sys world Automatic context help is disabled. Use the toolbart manually get help for the current caret position or to toggle automatic help. Tables 7 Tables city city country country countrylanguage Views countrylanguage Views Stored Procedures Functions Stored Procedures Functions Result Grid Result Grid Result Grid Administration Schemas Administration Schemas Herat Information Information Form Editor Edit: 43 Export/Import: Wrap Cell Content Percentage 5.3 9.5 76.7 7.4 0.9 32.1 52.4 Form Form Editor Result Grid 1 Filter Rows: ID Name CountryCode 1 kabul AFG 2 Qandahar AFG 3 Herat AFG 4 Mazar-e-Sharif AFG 5 Amsterdam NLD 6 Rotterdam NLD 7 Haag NLD 8 Utrecht NLD 9 Eindhoven NLD 10 NLD 11 Groningen NLD 12 Breda NLD city 1 x Editor Result Grid Filter Rows: CountryCode Language IsOfficial ABW Dutch T ABW English F ABW Papiamento F ABW Spanish F AFG Balochi F AFG Dari T AFG Pashto T AFG Turkmenian F AFG Uzbek F AGO Ambo F AGO Chokwe F AGO Kongo F trylanguage 1 x Edit: B Export/Import: Wrap Cell Content: A Fetch District Population Kabol 1780000 Qandahar 237500 186800 Balkh 127800 Noord-Holland 731200 Zuid-Holland 593321 Zuid-Holland 440900 Utrecht 234323 Noord-Brabant Noord-Brabant 193238 172701 Noord-Brabant 160398 Apply Result Grid Filter Rows: Code Name Continent ABW Aruba North America AFG Afghanistan Asia AGO Angola Africa AIA Anguilla North America ALB Albania Europe AND Andorra Europe ANT Netherlands Antilles North America ARE United Arab Emirates Asia ARG Argentina South America ARM Armenia Asia ASM American Samoa Oceania Schema:world Edit: 43 Export/Import: Wrap Cell Content Region Surface Area IndepYear Population Caribbean 193.00 NULL 103000 Southern and Central Asia 652090.00 1919 22720000 Central Africa 1246700.00 1975 12878000 Caribbean 96.00 NULL 8000 Southern Europe 28748.00 1912 3401200 Southern Europe 468.00 1278 78000 Caribbean 800.00 NULL 217000 Middle East 83600.00 1971 2441000 South America 2780400.00 1816 37032000 Middle East 29800.00 1991 3520000 Polynesia 199.00 NULL 68000 Schema:world Field 201843 ** Field Types 1.9 Field Types Types Tilburg 1.9 8.8 2.4 4.2 13.2 Groningen Revert Context Help Snippets Apply Revert Context Help Snippets country 1 x Apply Revert Context Help Snippets Output Output Output o Action Output # Action 1 18:12:24 SELECT * FROM world.city 2 18:12:28 SELECT * FROM world.country 3 18:12:40 SELECT * FROM world.countrylanguage Message 4079 row(s) retumed 239 row(s) retumed 984 row(s) retumed Duration / Fetch 0.000 sec /0.000 sec 0.000 sec / 0.000 sec 0.000 sec /0.000 sec o Action Output Time Action 1 18:12:24 SELECT * FROM world.city 2 18:12:28 SELECT * FROM world.country 3 18:12:40 SELECT * FROM world.countrylanguage Message 4079 row(s) retumed 239 row(s) retumed 984 row(s) returned Duration / Fetch 0.000 sec /0.000 sec 0.000 sec /0.000 sec 0.000 sec /0.000 sec o Action Output Time Action 1 18:12:24 SELECT * FROM world.city 2 18:12:28 SELECT * FROM world.country 3 18:12:40 SELECT * FROM world.countrylanguage Message 4079 row(s) retumed 239 row(s) retumed 984 row(s) retumed Duration / Fetch 0.000 sec /0.000 sec 0.000 sec / 0.000 sec 0.000 sec /0.000 sec OO O Object Info Session Object Info Session |3 Query Completed Query Completed
the following tables.
Questions:
How many languages are there?
What's the most commonly spoken language?
Which countries speak those languages?
Which countries have the largest
population?
What's the most commonly spoken language in the country
with the largest population?
How many cities speak the most popular
language?
What's the largest populated city that speaks the most
popular language?
What's the second most popular language?
Which countries have English as their most popular
language?
Example that was given was:
SELECT continent,name FROM world x
WHERE x.name <= ALL (
SELECT name FROM world y
WHERE x.continent=y.continent)
Х MySQL Workbench х MySQL Workbench Х Local instance MySQL80 (rela.. X Local instance MySQL80 (rela.. X (rela... x tabase Server Tools Scripting Help Edit View Query Database Server Tools Scripting Help File Edit View Query Database Server Tools Scripting Help File SOL 8 SQL 9 SOL SOL 9 @NO world x- city country countrylanguage world_x city country countrylanguage x world_x city country countrylanguage SQL Additions TO Jump to SQL Additions I 1 Jump to SQL Additions I 1 Jump to Dont Limit 7 Dont Limit INT Don't Limit SELECT * FROM world.city; 1. SELECT * FROM world.countrylanguage; 1. SELECT * FROM world.country; Automatic context help i: disabled. Use the toolbar || manually get help for the current caret position or t toggle automatic help. Navigator SCHEMAS a Filter objects drinks relational_database sakila sys world Automatic context help is disabled. Use the toolbart manually get help for the current caret position or to toggle automatic help. Navigator SCHEMAS a Filter objects drinks ► relational_database sakila sys world Automatic context help is disabled. Use the toolbart manually get help for the current caret position or to toggle automatic help. Tables 7 Tables city city country country countrylanguage Views countrylanguage Views Stored Procedures Functions Stored Procedures Functions Result Grid Result Grid Result Grid Administration Schemas Administration Schemas Herat Information Information Form Editor Edit: 43 Export/Import: Wrap Cell Content Percentage 5.3 9.5 76.7 7.4 0.9 32.1 52.4 Form Form Editor Result Grid 1 Filter Rows: ID Name CountryCode 1 kabul AFG 2 Qandahar AFG 3 Herat AFG 4 Mazar-e-Sharif AFG 5 Amsterdam NLD 6 Rotterdam NLD 7 Haag NLD 8 Utrecht NLD 9 Eindhoven NLD 10 NLD 11 Groningen NLD 12 Breda NLD city 1 x Editor Result Grid Filter Rows: CountryCode Language IsOfficial ABW Dutch T ABW English F ABW Papiamento F ABW Spanish F AFG Balochi F AFG Dari T AFG Pashto T AFG Turkmenian F AFG Uzbek F AGO Ambo F AGO Chokwe F AGO Kongo F trylanguage 1 x Edit: B Export/Import: Wrap Cell Content: A Fetch District Population Kabol 1780000 Qandahar 237500 186800 Balkh 127800 Noord-Holland 731200 Zuid-Holland 593321 Zuid-Holland 440900 Utrecht 234323 Noord-Brabant Noord-Brabant 193238 172701 Noord-Brabant 160398 Apply Result Grid Filter Rows: Code Name Continent ABW Aruba North America AFG Afghanistan Asia AGO Angola Africa AIA Anguilla North America ALB Albania Europe AND Andorra Europe ANT Netherlands Antilles North America ARE United Arab Emirates Asia ARG Argentina South America ARM Armenia Asia ASM American Samoa Oceania Schema:world Edit: 43 Export/Import: Wrap Cell Content Region Surface Area IndepYear Population Caribbean 193.00 NULL 103000 Southern and Central Asia 652090.00 1919 22720000 Central Africa 1246700.00 1975 12878000 Caribbean 96.00 NULL 8000 Southern Europe 28748.00 1912 3401200 Southern Europe 468.00 1278 78000 Caribbean 800.00 NULL 217000 Middle East 83600.00 1971 2441000 South America 2780400.00 1816 37032000 Middle East 29800.00 1991 3520000 Polynesia 199.00 NULL 68000 Schema:world Field 201843 ** Field Types 1.9 Field Types Types Tilburg 1.9 8.8 2.4 4.2 13.2 Groningen Revert Context Help Snippets Apply Revert Context Help Snippets country 1 x Apply Revert Context Help Snippets Output Output Output o Action Output # Action 1 18:12:24 SELECT * FROM world.city 2 18:12:28 SELECT * FROM world.country 3 18:12:40 SELECT * FROM world.countrylanguage Message 4079 row(s) retumed 239 row(s) retumed 984 row(s) retumed Duration / Fetch 0.000 sec /0.000 sec 0.000 sec / 0.000 sec 0.000 sec /0.000 sec o Action Output Time Action 1 18:12:24 SELECT * FROM world.city 2 18:12:28 SELECT * FROM world.country 3 18:12:40 SELECT * FROM world.countrylanguage Message 4079 row(s) retumed 239 row(s) retumed 984 row(s) returned Duration / Fetch 0.000 sec /0.000 sec 0.000 sec /0.000 sec 0.000 sec /0.000 sec o Action Output Time Action 1 18:12:24 SELECT * FROM world.city 2 18:12:28 SELECT * FROM world.country 3 18:12:40 SELECT * FROM world.countrylanguage Message 4079 row(s) retumed 239 row(s) retumed 984 row(s) retumed Duration / Fetch 0.000 sec /0.000 sec 0.000 sec / 0.000 sec 0.000 sec /0.000 sec OO O Object Info Session Object Info Session |3 Query Completed Query Completed