Calculate Total Sales with SELECT Expressions
📖 Scenario: You work for a small store that keeps track of products and their sales. You want to calculate the total sales amount for each product by multiplying the quantity sold by the price per unit.
🎯 Goal: Create a SQL query that selects the product name, quantity sold, price per unit, and calculates the total sales amount using an expression in the SELECT statement.
📋 What You'll Learn
Create a table called
sales with columns product (text), quantity (integer), and price_per_unit (decimal).Insert three rows into the
sales table with exact values: ('Apple', 10, 0.5), ('Banana', 5, 0.3), ('Cherry', 20, 0.2).Write a SELECT query that retrieves
product, quantity, price_per_unit, and a calculated column total_sales which is quantity * price_per_unit.Alias the calculated column as
total_sales.💡 Why This Matters
🌍 Real World
Stores and businesses often calculate total sales or revenue by multiplying quantity sold by price per unit to understand product performance.
💼 Career
Knowing how to write SELECT queries with calculations is essential for data analysts and database professionals to generate meaningful reports.
Progress0 / 4 steps