I'm trying to create a sql query by which the 2nd and 3rd case statement must be based on the 1st case statement .
My question is can we create 2nd and 3rd case using the result from 1st case statement in a single query.
Below is my query,when i run it,for example my uompointer=1800,my cq=1800,then based on the 2nd case statement,my arstat support to be Complete, but it display Partial.
when a.articleno='B0-015'then substring_index(a.qty*1,'+',1)
when a.articleno='B0-001'then substring_index(a.qty*1,'+',1)
when a.articleno='01-035' then substring_index(a.qty*2,'+',1)
when ifnull(b.cq,0) = 0 then '-'
when ((uompointer) - ifnull(b.cq,0)) <= 0 then 'Complete'
when ((uompointer) - ifnull(b.cq,0)) <= 0 then b.enddate
from schedule as a
left join (
select idschedule, sum(inflate) as cq, min(date(logDate)) as startdate, max(date(logDate)) as enddate
where isvalid = '1'
group by idschedule
left join product as e on(a.articleno=e.articleno)
where a.isvalid = '1'
order by a.shipdate
Can anybody assist me on this error?
Dec 04 at 08:15 AM