Two customers spend ₹1,000 each. The sales dashboard counts both orders correctly and reports ₹4,000 in revenue.
One basket holds a notebook, pens and a ₹150 mug. When the sales manager selects Stationery , should the mug count?
The dashboard joins orders to line items to make that filter possible. Even with All products selected, the query adds each order’s full value once per matching line.
How one ₹1,000 order becomes ₹3,000 in a SQL join
Take two paid orders. In this example, revenue is the amount paid for the items, and the line amounts add up to each order total. Order 101 is the three-item basket. Order 102 contains a single desk lamp.
Here’s what the data looks like after joining orders to order_items on order_id .
Order ID Item Category Line amount Order total
101 Notebook Stationery ₹600 ₹1,000
101 Pens Stationery ₹250 ₹1,000
101 Mug Homeware ₹150 ₹1,000
102 Desk lamp Homeware ₹1,000 ₹1,000
Read across the mug row. The ₹150 is the price of the mug.…