我有这个问题:
select itinerary.id as "itin_id", itinerary.`name`,
count((CASE WHEN(year(starts_on) = 2017) and (sign_up_date <= "2017-11-02") THEN 1 END)) AS `2017_sign_ups`
FROM `departure`
JOIN `itinerary` on `itinerary`.`id` = `departure`.`itinerary_id`
Join reservation on departure.id = reservation.departure_id
WHERE itinerary.trip_type not in ("V")
and reservation.`status` = "A"
and itinerary.season >= 2017
group by itinerary.id
我基本上需要弄清楚如何包含这个逻辑: 如果记录的状态为已取消,则计算cancel_date&lt; = some_date的情况,同时还计算具有活动状态的所有记录。
对不起,如果这是非常明显的东西,仍然找到我的Mysql腿。
由于