I have a subquery in a very large query that has to do the following
with an array of couples of clusters
array(array(c1, c2), array(c3, c4), array(c5, c6), array(c7, c8))
where for example c1 and c2 are complementary, c3 and c4 as well ..etc . and i have a table state :
id_state cluster successfull failed success_ratio
1 c1 4 0 100%
2 c2 1 9 10%
3 c3 0 4 0%
4 c4 1 1 50%
note that which cluster is coupled with the another is determined using the array above.
and the final output that i would like to have :
cluster successfull success_ratio
c1 4 100% (for the first pair)
c4 1 50% (for the second)
is there a way to do a query that gets the success_ratio of all the data by taking only from each couple the one with the success_ratio > 50% and only if both have success_ratio < 50% then just take the first one.
Is this even achievable using only a mysql query (i can't use query result since i want it as a subquery of another large query) ?
even if you can just suggest a starting point for a way to do it that would be appreciated.