Hi,today I struggle a bit with my Case When condition and hope you can help me. I have the following:MAX(Vernum) AS test,MAX(Case WHEN A2.AttrID = 2 AND A2.DefID = 10057945 THEN A2.ValStr END) AS TYPE_DOCUMENT
This works not perfect. In many cases I have more then one row and my query takes the max value of column Valstr. Thats is not exactly what I want. I'd like to have the value of Column Valstr of the row where column Vernum has the maximum value.I've tried many things like:MAX(Vernum) AS test,MAX(Case WHEN A2.AttrID = 2 AND A2.DefID = 10057945 AND A2.Vernum=test THEN A2.ValStr END) AS TYPE_DOCUMENT
ORMAX(Vernum) AS test,MAX(Case WHEN A2.AttrID = 2 AND A2.DefID = 10057945 AND A2.Vernum=MAX(A2.Vernum) THEN A2.ValStr END) AS TYPE_DOCUMENT[/code]I hope you understand what I mean.:) How can I get the value of one column and have the maximum condition of another column?Kind regards,Lara