Question

I have this answer: SELECT c.Code, count(*) FROM country c JOIN countrylanguage cl ON c.Code =...

I have this answer:

SELECT c.Code, count(*) FROM country c JOIN countrylanguage cl ON c.Code = cl.CountryCode GROUP BY cl.CountryCode HAVING COUNT(*) > 1 LIMIT 10;

From a previous question I asked which was:

Using the database you installed from the link below, provide an example query using both a group by clause and a having clause. Show no more than ten rows of your query result. Discuss if the query you wrote can be rewritten without those clauses.

The sample database that this is based off of can be found at https://dev.mysql.com/doc/index-other.html under example databases, world_x database.

******************************

What I need Now is:

Could you please explain the query that is written above as well as if it can be re-written without the clauses and why?

Thank you

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

This query returns the country and the number of languages spoken for each country if and only there are atleast 2 different languages spoken. The LIMIT 10 limits the result to 10 rows.

No, the query cannot be written without these clauses since we want to group similar countries together in order to sum up the number of languages spoken in each country. Without the GROUP BY clause, it is impossible to group the countries together.

Add a comment
Know the answer?
Add Answer to:
I have this answer: SELECT c.Code, count(*) FROM country c JOIN countrylanguage cl ON c.Code =...
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
  • I have this answer: SELECT c.Code, count(*) FROM country c JOIN countrylanguage cl ON c.Code = cl.CountryCode GROUP BY c...

    I have this answer: SELECT c.Code, count(*) FROM country c JOIN countrylanguage cl ON c.Code = cl.CountryCode GROUP BY cl.CountryCode HAVING COUNT(*) > 1 LIMIT 10; From a previous question I asked which was: Using the database you installed from the link below, provide an example query using both a group by clause and a having clause. Show no more than ten rows of your query result. Discuss if the query you wrote can be rewritten without those clauses. The...

  • I need help with the following problem: Using the classicmodels database you installed from Module 1,...

    I need help with the following problem: Using the classicmodels database you installed from Module 1, provide an example query using both a group by clause and a having clause. Show no more than ten rows of your query result. Discuss if the query you wrote can be rewritten without those clauses. I have come up with the following for the first part of the question: mysql> select offices.city, count(employees.employeenumber) as NumberOfEmployees from Employees -> inner join offices on offices.officecode...

  • Please can I have the solution to this problem? Exercise 25.4 Briefly answer the following questions:...

    Please can I have the solution to this problem? Exercise 25.4 Briefly answer the following questions: 1. What is the difIerences between the WINDOW clause and the GROUP BY clause'? 2. Give an example query that cannot be expressed in SQL without the WINDOW clause but that can be expressed with the WINDOW clause. :3. What is the fTCLrne of a window in SQL:19997 4. Consider the fonowing simple GROUP BY query. SELECT FROM WHERE GROUP BY T.year, SUM (S.sales)...

  • Top of Form Q1 Which of the following is a valid aggregate function in SQL? Check...

    Top of Form Q1 Which of the following is a valid aggregate function in SQL? Check only those that apply. Question 1 options: AVG LEAST COUNT MIN MOST SUM Q2 Which of the following aggregate functions will only operate on a numeric value expression? Check only those that apply: Question 2 options: MIN MAX AVG COUNT SUM Q3 When applying DISTINCT to the value being calculated in an aggregate function like COUNT, what is the effect? SELECT COUNT(DISTINCT StreetName) FROM...

  • 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...

  • I need a response in your opinion, from this answer Q1. Any user accessing the database is more i...

    I need a response in your opinion, from this answer Q1. Any user accessing the database is more interested in quick and correct result than how a database is designed. Hence if we introduce redundancy in the table and if the performance of the query increases, then we can ignore 3NF. This is known as denormalization. In this process, a normalized table will be rejoined to have the redundancy in the table to increase the performance of the query. Denormalization...

  • 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...

  • Consider the table actor which already exists in our database, with 200 rows. Upon executing SHOW...

    Consider the table actor which already exists in our database, with 200 rows. Upon executing SHOW CREATE TABLE `actor`, we get the following: CREATE TABLE `actor` ( `actor_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(10) NOT NULL, `last_name` varchar(10) NOT NULL, `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`actor_id`), KEY `idx_actor_last_name` (`last_name`) ) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8 You will need this table for any questions below which refer to an `actor` table. 1. Using the actor...

  • Hospital Patient Reglstration System Hospltal Patient Registration System Part 2: Relational Sche...

    Hospital Patient Reglstration System Hospltal Patient Registration System Part 2: Relational Schema: Description of Tables 1) 2) Patient Table: Contains detail information about patients. Patient Address: Contains list of patients addresses. Each Patient can have more than one Address. However, an address can belong to only one patient. DOD DATETM 3) Provider Table: Contains detail information about Service Provider's, 4) Provider Address: Contains list of provider's addresses. 5) Provider Department: Contains information about which provider are in which department. Provider...

  • Using mySQL, tables at the end... This assignment uses the tables from the vets database. The goa...

    Using mySQL, tables at the end... This assignment uses the tables from the vets database. The goal of the assignment is to get you to think about joins- inner join and outer joins.  If you do a join, where you have the names of two or more tables in the From clause, then you must use the condition join syntax or the column name join. Take care that you do not accidentally do a Cartesian product. If your result set...

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