Untitled
unknown
plain_text
2 years ago
545 B
6
Indexable
CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_calculate_revenue`(
IN startDate DATE,
IN endDate DATE
)
BEGIN
SELECT
cod.CustomerOrderId,
co.OrderDate,
co.Status,
SUM(cod.Quantity * cod.Price) AS Revenue
FROM
( SELECT
CustomerOrderId, OrderDate, Status
FROM
CustomerOrder
WHERE
(OrderDate BETWEEN startDate AND endDate) AND (Status = 'Done')) co
INNER JOIN CustomerOrderDetail cod ON co.CustomerOrderId = cod.CustomerOrderId
GROUP BY
co.CustomerOrderId, co.OrderDate, co.Status;
ENDEditor is loading...