I'm trying to combine the result of a CASE into an IF Statement, however the result is an error.
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 [...]
and the error is: Unknown column 'active' in 'field list'
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire