The document outlines a lab activity involving SQL statements to create two tables: e_products and sales, with specified columns. It includes various SQL queries to retrieve and manipulate data from these tables, such as filtering products by category, calculating total revenue, and retrieving specific columns. The activity aims to enhance understanding of SQL operations in a practical context.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
147 views2 pages
ADS Lab Activity No 2 ANSWER KEY
The document outlines a lab activity involving SQL statements to create two tables: e_products and sales, with specified columns. It includes various SQL queries to retrieve and manipulate data from these tables, such as filtering products by category, calculating total revenue, and retrieving specific columns. The activity aims to enhance understanding of SQL operations in a practical context.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Name: Date:
Section:
LAB ACTIVITY NO. 2
INSTRUCTIONS: Use the SQL statement below to create the sales and e_products table with the specified columns Write SQL queries to answer the questions.
SELECT * FROM Sales; (I considered the other answers) 2. Retrieve the product_name and unit_price from the e_products table. SELECT product_name, unit_price FROM e_products; 3. Retrieve the sale_id and sale_date from the Sales table. SELECT sale_id, sale_date FROM Sales; 4. Filter the Sales table to show only sales with a total_price greater than $100. SELECT * FROM Sales WHERE total_price > 100; 5. Filter the e_products table to show only products in the 'Electronics' category. SELECT * FROM e_products WHERE category = 'Electronics'; 6. Retrieve the sale_id and total_price from the Sales table for sales made on January 3, 2024. SELECT sale_id, total_price FROM Sales WHERE sale_date = '2024-01-03'; 7. Calculate the total revenue generated from all sales in the Sales table. SELECT SUM(total_price) AS total_revenue FROM Sales; 8. Calculate the average unit_price of products in the e_products table. SELECT AVG(unit_price) AS average_unit_price FROM e_products; 9. Calculate the total quantity_sold from the Sales table. SELECT SUM(quantity_sold) AS total_quantity_sold FROM Sales; 10. Count Sales Per Day from the Sales table SELECT sale_date, COUNT(*) AS sales_count FROM Sales GROUP BY sale_date ORDER BY sale_date; 11. Retrieve product_name and unit_price from the e_products table with the Highest Unit Price SELECT product_name, unit_price FROM e_products ORDER BY unit_price DESC LIMIT 1; 12. Retrieve the total_price of all sales, rounding the values to two decimal places. SELECT ROUND(SUM(total_price), 2) AS total_sales FROM Sales; 13. Calculate the average total_price of sales in the Sales table. SELECT AVG(total_price) AS average_total_price FROM Sales; 14. SELECT sale_id, DATE_FORMAT(sale_date, '%Y-%m-%d') AS formatted_date FROM Sales; 15. Retrieve the product_name and unit_price from the e_products table, filtering the unit_price to show only values between $20 and $600. SELECT product_name, unit_price FROM e_products WHERE unit_price BETWEEN 20 AND 600;