这是查询的一部分
SELECT
`delivery-types`.`delivery-types_name`,
SUM(CASE `order`.order_status
WHEN 'fake' THEN 1
ELSE 0
END) AS total,
MAX(deliverability.delivery_first_week_repo.from_sale) AS top
FROM
`delivery-types`
LEFT JOIN
deliverability.delivery_first_week_repo ON `delivery-types`.`delivery-types_name` = delivery_first_week_repo.type
INNER JOIN
order_delivery ON `delivery-types`.`delivery-types_code` = order_delivery.order_delivery_code
INNER JOIN
`order` ON order_delivery.order_id = `order`.order_id
WHERE
delivery_first_week_repo.week_day = DAYNAME(CURRENT_DATE())
AND order_delivery_code IN ('cream-ec' , 'courier')
AND order_createdAt >= CURRENT_DATE - INTERVAL (7 + (5 + DAYOFWEEK(CURRENT_DATE)) % 7) DAY
AND order_createdAt <= CURRENT_DATE - INTERVAL (0 + (5 + DAYOFWEEK(CURRENT_DATE)) % 7) DAY
GROUP BY deliverability.delivery_first_week_repo.from_sale
HAVING MAX(deliverability.delivery_first_week_repo.from_sale);