The following example uses a Valued CASE expression to calculate the fraction of cost in the total cost of inventory represented by parts of type ‘1’:
SELECT SUM(CASE part WHEN '1' THEN cost ELSE 0 END )/SUM(cost) FROM t;
The following example uses a Valued CASE expression to calculate the fraction of cost in the total cost of inventory represented by parts of type ‘1’:
SELECT SUM(CASE part WHEN '1' THEN cost ELSE 0 END )/SUM(cost) FROM t;