Question

1.If you do not have the world schema you can obtain the scripts to create the...

1.If you do not have the world schema you can obtain the scripts to create the database schema from https://dev.mysql.com/doc/index-other.html

Queries

1. Write a SQL subquery that shows the unique region names where the languages spoken are English, French or German.

2. Write a SQL query that shows the country name, region, language for the Caribbean region

3. Write a SQL query that shows the country name once and shows the number of cities in that country. The number of cities in the country is from the City table and should have an alias of NumberofCity.

4. Write a SQL query that shows the country name and number of official languages with an alias NumberOfficial. Please note the condition is asking for the count where IsOfficial is true. The results need to be sorted by number of official languages (NumberOfficial) in descending order.

5. Write a SQL query that shows the country name and number of official languages with an alias NumberOfficial. Please note the condition is asking for the count where IsOfficial is true. Also, the results should show only if the count of the number of official languages is greater than 2. The results need to be sorted by number of official languages (NumberOfficial) in descending order.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Query

/*1. Write a SQL subquery that shows the unique region names where the languages spoken are English, French or German.*/
Select Name from country where Code in(Select CountryCode from countrylanguage where Language in('English','French','German'));


/* 2. Write a SQL query that shows the country name, region, language for the Caribbean region*/
   Select country.Name,region,GROUP_CONCAT( Language ) as "Language"from country inner join countrylanguage on country.Code=countrylanguage.CountryCode where region='Caribbean' group by country.Name;


/* 3. Write a SQL query that shows the country name once and shows the number of cities in that country. The number of cities in the country is from the City table and should have an alias of NumberofCity.*/
   Select country.Name,GROUP_CONCAT(City.Name) as "City" from country inner join City on country.Code=City.CountryCode group by country.Name;


/*4. Write a SQL query that shows the country name and number of official languages with an alias NumberOfficial. Please note the condition is asking for the count where IsOfficial is true. The results need to be sorted by number of official languages (NumberOfficial) in descending order.*/
Select country.Name,count(*)"NumberOfficial" from country inner join countrylanguage on countrylanguage.CountryCode=country.Code where IsOfficial='T' group by country.Name;


/* 5. Write a SQL query that shows the country name and number of official languages with an alias NumberOfficial. Please note the condition is asking for the count where IsOfficial is true. Also, the results should show only if the count of the number of official languages is greater than 2. The results need to be sorted by number of official languages (NumberOfficial) in descending order.*/
Select country.Name,count(*)"NumberOfficial" from country inner join countrylanguage on countrylanguage.CountryCode=country.Code where IsOfficial='T' group by country.Name having count(*)>2 order by NumberOfficial desc;

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........

Add a comment
Know the answer?
Add Answer to:
1.If you do not have the world schema you can obtain the scripts to create the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • SQL Queries – in this assignment you will be asked to create several SQL queries relating...

    SQL Queries – in this assignment you will be asked to create several SQL queries relating to the Sakila database that we installed in class. You may freely use DBeaver to create these queries, but I will expect your solution to show me the SQL code to answer or complete the tasks below. Write a query that produces the last name, first name, address, district, and phone number for every customer in the customer table. (You don’t need to include...

  • can someone solve these quick please and thank you! sql chapter 4 Query #1: List the...

    can someone solve these quick please and thank you! sql chapter 4 Query #1: List the company name, contact name, contact title and the phone number for customers who HAVE NOT put in an order. Use an outer join. Query #2: Create a listing displaying the employee first name, last name and the full name (First name space Last Name) of the person they report to (Supervisor). This is a self-join. If an employee does not report to anyone then...

  • Summarize these pages in your own style and you have to include in your report some...

    Summarize these pages in your own style and you have to include in your report some figures highlighting the relation between these operations. Basic AGGREGATE functions (Revision) COUNT: returns the number of tuples, which meet the specified condition: SELECT COUNT(DISTINCT Dept) AS Num_Depts FROM subject: SUM: returns the sum of the values in a specified column (i.e. numeric column) SELECT COUNT(*) AS hi_sal, SUM(salary) FROM Lecturer WHERE Salary > 4500 MIN: returns the minimum value in a specified column (numeri...

  • Put all of your SQL code in a file named grades.sql and submit it below. Download...

    Put all of your SQL code in a file named grades.sql and submit it below. Download the starter code, which contains import_grades.sql and the grades.csv file. Using he import_grades, sql file, create your database and table. - 0 eded. 1 T Une Modify the LOAD DATA INFILE to correct the path to load the grades.csv file, and add/remove LOCAL he only modification you may make to the import_grades.sql or the grades.csv files. The data represents grades for assignments in a...

  • You will develop an E-Commerce database used to maintain customers, products and sales information. You are...

    You will develop an E-Commerce database used to maintain customers, products and sales information. You are required to 1) gather and analyze requirements 2) design logical structure of the database 3) create stored procedures to develop the tables and insert the data 4) write SQL statements for data extraction and reporting. Throughout the course of this semester you have analyzed the requirements for an eCommerce database, designed and developed your database. As a class we have gone through the process...

  • Write Ten SQL SELECT statements to query the STUDENT schema you created for practice lab. 4....

    Write Ten SQL SELECT statements to query the STUDENT schema you created for practice lab. 4. List all cities that have 10 or more students and instructors combined. Show city, state, number of student residents, number of instructor residents, and total student/instructor residents in that city. Sort by total in descending order. 5. List the instructor id and name of the instructors that teach fewer than 10 sections. 7. Find how many students are enrolled in sections taught by Todd...

  • This is about database system. Thank you. Question B1 Create a Crow's Foot ERD with the...

    This is about database system. Thank you. Question B1 Create a Crow's Foot ERD with the business rules described below. Write all appropriate connectivities and cardinalities in the ERD. A music store would like to develop a database to manage information about the CDs, or vinyl collection, the customers and transactions information. It stores the relationships between artists, albums, tracks, customers and transactions. Here is the list of requirements for the database: The collection consists of albums. An album is...

  • Database Intro Salesmen Sheet Order_info Sheet Business_Info sheet 1.Create your own table design based on the...

    Database Intro Salesmen Sheet Order_info Sheet Business_Info sheet 1.Create your own table design based on the Excel data, and include all relationships (joins). Apply referential integrity rules wherever appropriate. Import the data from Excel to Access to populate tables: 1. Use the Chen technique and illustrate the E-R diagram for the tables you created Note: It may be necessary to change the data composition due to normalization issues, if you change the composition detail how and why; (you may find...

  • QUESTION 1: Why must project manager should have good technical skills but also good management skills?...

    QUESTION 1: Why must project manager should have good technical skills but also good management skills? QUESTION 2: **Communication and Communicator are related" This quote from the text suppose that the communication process is lead by the spokeperson. Do you think is it a gift" to be a good communicator or a skill to improve ( use example of your knowledge to answer)? QUESTION 3: Look at the text paragraph yellow highlighted, and do you think that in today's world...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT