vendredi 22 juillet 2016

SQL Server : get max of the column2 and column3 value must be 1

I have an output of some part of my stored proedure like this:

col1      col2  col3 col4
--------------------------
2016-05-05  1    2      2
2016-05-05  1    3     32
2016-05-12  2    1     11
2016-05-12  3    1     31

Now I need to get result based on this condition

col2 = 1 and col3 = max or col3 = 1 
and col2 = max

The final result should be

col1      col2  col3 col4
-------------------------
2016-05-05  1    3     32
2016-05-12  3    1     31

Aucun commentaire:

Enregistrer un commentaire