Excel → T-SQL › SUMPRODUCT
SUMPRODUCT to SQL SUM of products
Most workplace SUMPRODUCTs are SUMIFS in a trench coat. The honest ones multiply two columns.
SELECT SUM(CASE WHEN status = 'Shipped' THEN total_amount ELSE 0 END)
FROM Orders;
-- actual product of two columns
SELECT SUM(qty * unit_price) FROM OrderLines;
Do not multiply whole columns in SQL. That is a CROSS JOIN of the sheet against itself.
Canonical translation
SELECT SUM(CASE WHEN status = 'Shipped' THEN total_amount ELSE 0 END)
FROM Orders;
-- actual product of two columns
SELECT SUM(qty * unit_price) FROM OrderLines;
Then write it on a ticket
Monday is free. A colleague asks, you type, we mark it.
Clock in free