I have a table XYZ as
+------+------+------+-----+ | X1 | x2 | x3 | x4 | +------+------+------+-----+ | a | b | c | 1 | | a | b | d | 2 | | p | q | e | 3 | | p | q | f | 4 | +------+------+------+-----+
condition is if x1 and x2 matches then get x3 and x4 of row where x4 is maximum when i will query this table I want to get output as
+------+------+------+-----+ | X1 | x2 | x3 | x4 | +------+------+------+-----+ | a | b | d | 2 | | p | q | f | 4 | +------+------+------+-----+
i tried as select * from XYZ t1, (select x1,x2,max(x4) from XYZ ) t2 where t1.x1=t2.x1 and t1.x2=t2.x2
but i want to use advance functions like rank and partations as this is much slow in large database