[MYSQL] 최댓값보다 x%가 감소했을때
1 2 3 4 5 6 7 8 9 10 11 12 13 //부모테이블과 자식테이블은 1:n관계를 가짐 SELECT 100-((A.last_wgt*100)/max_wgt) as downper, // 몇% 감소했는지 if(A.max_wgt*0.8>A.last_wgt,'red',0) as red, // 20%감소했을때 if(A.max_wgt*0.9>A.last_wgt,'orange',0) as orange // 10%감소했을때 FROM ( SELECT (select max(weight) from CHILD_TABLE B where A._no = B._no) max_wgt, (select weight from CHILD_TABLE B where A._no = B._no order by B.reg_dt desc l..