Calculate Total Sales Using SUM Function
📖 Scenario: You work at a small store that keeps track of daily sales in a database table. You want to find out the total amount of sales made so far.
🎯 Goal: Build a SQL query that calculates the total sales amount from the sales table using the SUM function.
📋 What You'll Learn
Create a table called
sales with columns id (integer) and amount (decimal).Insert exactly three rows into the
sales table with amounts 100.50, 200.75, and 50.25.Write a SQL query that uses the
SUM function on the amount column.Name the result column as
total_sales.💡 Why This Matters
🌍 Real World
Stores and businesses often need to calculate total sales or revenue from their sales data stored in databases.
💼 Career
Knowing how to use aggregate functions like SUM is essential for data analysis roles, reporting, and database management.
Progress0 / 4 steps