Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MySQL SQL SUM() A sql-6-5.sql file has been opened for you. Write each of the fo

ID: 3905081 • Letter: M

Question

MySQL

SQL SUM()

A sql-6-5.sql file has been opened for you.

Write each of the following tasks as a SQL statement in a new line (remember that you can source the file to compare the output reference):

1 - Use the e_store database

2 - Select the total stock of all products in the products table. Alias the column name as total_stock. The resulting table should look like this:

3 - Select the total stars of the product with id = 4. Alias the column name as total_stars. The resulting table should look like this:

Explanation / Answer

1). To use e_store database you need to use the command: use e_store;

2). To find total stock the command is: select count(*) as total_stock from products;

3). To avchieve the third output: select id, sum(stars) from products where product id=4;

Please comment if you face any difficulty.