MySQL Forums
Forum List  »  Newbie

Math Calculation with multiple where condition
Posted by: Loginthiren Mathalagan
Date: May 29, 2018 10:21PM

Formula math:
1) Filter TRACK-OUT and TRACK-IN and coreid like '%-S% and '%-D%'

2) actual_Sout (for filter '%-S%') = Track Sout (filter from TRACK-OUT) - Track Sin (filter from TRACK-IN)

3) actual_Dout (for filter '%-D%') = Track Dout (filter from TRACK-OUT) - Track Din (filter from TRACK-IN)

4) RatioS (ratio for S) = actual_Sout / (actual_Sout + actual_Dout) * 100
5) RatioD (ratio for D) = actual_Dout / (actual_Dout + actual_Sout) * 100


Below query only able to get data, if write all other above steps into this query, it's getting errors, how to write all other step with below query?
I'm very new for this complex math query. need help.

select 'Single' as coretype,
count(distinct SUBSTRING_INDEX(Sout.coreid,'-','1')) - (select count(distinct SUBSTRING_INDEX(Sin.coreid,'-','1'))
FROM inari_laravel.wafersort_trackrecord as Sin where Sin.item ='CORE' and Sin.track_record='TRACK-IN'
and Sin.coreid like '%-S%') as Total_Actual_out
FROM inari_laravel.wafersort_trackrecord as Sout where Sout.item ='CORE' and Sout.track_record='TRACK-OUT'
and Sout.coreid like '%-S%';

Options: ReplyQuote


Subject
Written By
Posted
Math Calculation with multiple where condition
May 29, 2018 10:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.