Question

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 rename the column to NumberofRobots


Q3) By looking at film table.
How many films we have that its description contains the word "Truman".

Count number of films and rename the column to NumberofTruman

Q4) By looking at film table.

How many films we have that its description contains the word “ Robot” or "Truman". Count number of films and rename the column to RobotORTruman

Q5) By looking at film table.

How many films we have that its description contains the word “ Robot” and "Truman". Count number of films and rename the column to RobotANDTruman

Q6) By looking at film table.

Group film by special_features and count how many films are in each special features. Rename the column to NumberofFilms

Q7) By looking at film table.

Order query 6 by NumberofFilms in descending format.

Homework Answers

Answer #1

Question 1:

SQL query :

select count(city_id) as TotalNumberOfCities from city;

  • This SQL query is using count() function to count the total cities.

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

Question 2:

SQL query :

select count(film_id) as NumberofRobots from film where description like '%Robot%';

  • This SQL query is using count() function to count the films that contains word Robot in the description along with like clause

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

Question 3:

SQL query :

select count(film_id) as NumberofTruman from film where description like '%Truman%';

  • This SQL query is using count() function to count the films that contains word Truman in the description along with like clause

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

Question 4:

SQL query :

select count(film_id) as RobotORTruman from film where
description like '%Robot%' or
description like '%Truman%';

  • This SQL query is using count() function to count the films that contains word Truman or Robort in the description along with like clause

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

Question 5:

SQL query :

select count(film_id) as RobotANDTruman from film where
description like '%Robot%' AND
description like '%Truman%';

  • This SQL query is using count() function to count the films that contains word Truman and Robort in the description along with like clause

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

Question 6:

SQL query :

select special_features, count(film_id) as NumberofFilms from film
group by special_features;

  • This SQL query will group the films by special features.

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

Question 7:

SQL query :

select special_features, count(film_id) as NumberofFilms from film
group by special_features
order by NumberofFilms desc;'

  • This SQL query will group the films by special features and order the records by NumberofFilms in descending orders

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

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
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....
4-16 In MySql, using Application MYSQL Workbench and the Chinook database, please write a query to...
4-16 In MySql, using Application MYSQL Workbench and the Chinook database, please write a query to answer this? -- 16. Display the ablumid, the title, and the length of each title for each row in the album table. Number 16 - use LENGTH function I just need to add the Lenghth function to this answer: SELECT ArtistId, SUBSTRING(ArtistName, 1, 5) AS ArtistName FROM Artist;
Q1. Which of the following statements are false ? (a) Inside, outside and boundary are basic...
Q1. Which of the following statements are false ? (a) Inside, outside and boundary are basic topological operations. (b) 9-intersection model formalizes binary topological relationship. (c) Topological relationships change under elastic deformation. (d) Direction (e.g., North, left) is a topological relationship. Q2. Which of the following is not a topological query ? (a) Which country has highest number of neighboring countries? (b) List airports within 100 miles of Chicago, Illinois. (c) Which rivers flow via at least six countries? (d)...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment 4’s schema (Customer-Invoice-Line-Product-Vendor). Make sure that your SQL script runs without any errors. Submit your answers in a .SQL file. 1 (2 Points) - Find the count of distinctvendors thatsupplied products that are priced lowerthan 185? 2 (2 Points) - For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product description and product...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first,...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first, third, fifth (and so on) characters of the strings, with each character both preceded and followed by the ^ symbol, and with a newline appearing after the last ^ symbol. The function returns no value; its goal is to print its output, but not to return it. Q2) Write a Python function called lines_of_code that takes a Path object as a parameter, which is...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a small number of records. However, the data contained within it is expected to grow significantly in the future. Creating indexes on commonly searched columns is a way performance issues can be minimized. Write a command to create an index on student_name column of the student table. Create view – 1 mark Write a command to create a view to list the student ID and...
Challenge 5 Read ALL of the instructions carefully before starting the exercise! Dear Colleague, Earlier today...
Challenge 5 Read ALL of the instructions carefully before starting the exercise! Dear Colleague, Earlier today I built my fourth website using HTML5 and CSS3. This time I wanted to try using CSS float layout options on a website dedicated to my favorite topic: robotics. I wanted my website to look like what is shown in Figure 1 (see below). However, after giving it my best effort, things once again didn’t turn out the way I wanted (see the code...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code to initialize the CustomerAccountsDB database table and add a set of customer accounts is provided. Finish the code in these 3 methods in CustomerAccountDB.java to update or query the database: -purchase(double amountOfPurchase) -payment(double amountOfPayment) -getCustomerName() Hint: For getCustomerName(), look at the getAccountBalance() method to see an example of querying data from the database. For the purchase() and payment() methods, look at the addCustomerAccount() method...
Data For Tasks 1-8, consider the following data: 7.2, 1.2, 1.8, 2.8, 18, -1.9, -0.1, -1.5,...
Data For Tasks 1-8, consider the following data: 7.2, 1.2, 1.8, 2.8, 18, -1.9, -0.1, -1.5, 13.0, 3.2, -1.1, 7.0, 0.5, 3.9, 2.1, 4.1, 6.5 In Tasks 1-8 you are asked to conduct some computations regarding this data. The computation should be carried out manually. All the steps that go into the computation should be presented and explained. (You may use R in order to verify your computation, but not as a substitute for conducting the manual computations.) A Random...
1) Describe an example of each of the following that may be found of your kitchen:...
1) Describe an example of each of the following that may be found of your kitchen: Explain how your choice falls into this category, and if there is a chemical name or symbol for it, provide that as well. Provide a photo of your example with your ID card in it. a) a compound b) a heterogeneous mixture c) an element (symbol) Moving to the Caves… Lechuguilla Caves specifically. Check out this picture of crystals of gypsum left behind in...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT