228k views
0 votes
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): Use the e_store database 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:

User Santobedi
by
6.3k points

1 Answer

2 votes

Answer:

The query is as follows:

select sum(stock) as total_stock from products

Step-by-step explanation:

Required

Return total stock using the alias total_stock from the product table.

The explanation of the query is as follows:

select ----> This implies that data is to be selected from the table

sum(stock) ----> This adds up entries in stock column

as total_stock ---> This represents the alias used for sum(stock)column where

from products ----> The table being queried

Take for instance, the content of the table is:

SN Product Stock

1 Apple 5

2 Orange 3

3 Banana 8

The query will return the following table:

total_stock

16

User Alexei Sholik
by
7.7k points