我正在尝试将CASE的结果合并到IF语句中,但结果是错误。
SELECT *, [...],
(CASE
WHEN (Promotion.end > curdate() AND Promotion.start < curdate() ) THEN TRUE
WHEN (Promotion.end > curdate()) THEN 'future'
ELSE FALSE
END) as active,
(CASE
WHEN (Sitting.start > M.max_end ) THEN 'future'
WHEN (Sitting.start < M.max_end AND Sitting.start > M.min_start ) THEN TRUE
ELSE FALSE
END) as sitting_status,
SUM(IF( (amount>0 AND active=TRUE) or(amount<0 AND sitting_status=TRUE AND status=1),amount,0)) AS total_mysql [...]
,错误是:Unknown column 'active' in 'field list'
提前致谢