Thursday, 8 August 2013

how do I write an IF ELSE into this query to make it work?

how do I write an IF ELSE into this query to make it work?

table looks something like this
yes those are & signs. ignore the dashes
ID-VALUE-NUM
-1-YES----2-
-1-NO-----3-
-2-YES----1-
-2-NO-----1-
-3-&&&----1-
-3-&------2-
-3-&&-----2-
what I need to do: for each ID, I need to get the value with the highest
NUM, in the case of a tie and VALUE has &s then it would pick the
shortest. if the value is YES/NO then it will pick YES.
result desired
ID-VALUE-NUM
-1-NO-----3-
-2-YES----1-
-3-&------2-
I think I have to put a IF statement in there somewhere but I'm not sure how.
thanks!

No comments:

Post a Comment