Question

Open the World database on MySQL. Write the SQL code to display the name and population...

Open the World database on MySQL. Write the SQL code to display the name and population of all cities that meet two conditions:

a.) the city has a population more than 100,000; and

b.) the city name has (anywhere) the letter a followed by any character followed by the letter z.

Use a regular expression for the second condition. Sequence the query results in descending order by population. What is the city with the largest population in the output?

Homework Answers

Answer #1

SQL code for above question :

select city_name, population from WorldDatabase WHERE population>1,00,000 AND city_name LIKE '%a_z%' , '%A_Z%' ORDER BY population DESC;

The city with the largest population in the output will be the city name in the very first row of the output.

However u can also write sql query for finding the city with the largest population in the previous output satisfying both the conditions given in question. Here, is the sql query :

select city_name from WorldDatabase WHERE population>1,00,000 AND city_name LIKE '%a_z%' , '%A_Z%' ORDER BY population DESC LIMIT 1;

Know the answer?
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
Similar Questions
Consider Sakila Database. Write a query in mySQL workbench to answer each of following questions. Q1)...
Consider Sakila Database. Write a query in mySQL workbench to answer each of following questions. Q1) By looking at city table. Write a query that identify the in how many cities the company has branches. Rename the column name to TotalNumberOfCities. You have to look at city table and write a query to count number of rows. Q2) By looking at film table. How many films we have that its description contains the word "Robot". Count number of films and...
Write code in SQL. Q1) By looking at city table. Write a query that identify the...
Write code in SQL. Q1) By looking at city table. Write a query that identify the in how many cities the company has branches. Rename the column name to TotalNumberOfCities. You have to look at city table and write a query to count number of rows. Q2) By looking at film table. How many films we have that its description contains the word "Robot". Count number of films and rename the column to NumberofRobots Q3) By looking at film table....
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT