FOUNDATIONS-2: Money Math, Data Types & Cleaning Dirty Orders
Track: Analytics Foundations • Difficulty: Beginner • Mastery Points: 100 PTS
Business Problem Scenario
A small online coffee shop logs every checkout in bronze.coffee_orders. Unfortunately, the test team left negative test amounts (-5.00) in the table, and cancelled orders still sit next to completed orders. If finance sums every row, daily revenue will be wrong.
Engineering Objective
Summarize valid completed revenue by drink category. • Expected Columns: category, order_count, total_revenue • Filter Rules: - status = 'completed' - amount > 0 • Rounding & Sort: - total_revenue = ROUND(SUM(amount), 2) - ORDER BY total_revenue DESC
Target Table: bronze.coffee_orders (order_id TEXT, category TEXT, amount DECIMAL(10,2), status TEXT, order_date DATE)
Verification & Architecture Insights
Clean analytics always filters invalid statuses and impossible negative amounts before aggregating. In real warehouses, money columns should also use fixed-precision DECIMAL rather than floating-point numbers.