vendredi 20 février 2015

Select minimum value in columns after comparing each column to an input in sqlite

I have the following table:


Qual | C1 | C2 | C3 | C4 |


50 | 0.2 | 0.5 | 0.9 | 1.2 |


100 | 0.3 | 0.7 | 1.1 | 1.7 |


I have an inputX1 (for example 50) and another inputX2 (= 0.7) and I am going to compare inputX2 to each column of the row which has Qual=50. So first we get:


Qual | C1 | C2 | C3 | C4 |


50 | 0.2 | 0.5 | 0.9 | 1.2 |


and I want to get at the end "C2" returned, after comparing inputX2=0.7 to each column of this row because 0.7 is > 0.5 and 0.2 however it is less than 0.9 and 1.2 so it should go to the closest smaller value which is 0.5 of column C2. Is there any possible way to do this? Rebuilding the database schema is sort of not an option.Please help me guys. Thanks


Aucun commentaire:

Enregistrer un commentaire