computer consultant / programmer / linux sever adm,
September 23, 2010 at 8:41 PM
Your sql query: select Id, Name ,max(Marks) from stu group by id insn't correct and may produce non valid results. You are realy "lucky" that your exemple produced (in this case) the right results. To garantie all time correct results you should replace your query by the following one:
SELECT Id, Name, Marks FROM stu WHERE (Marks, Id) IN ( SELECT max(Marks), Id FROM stu GROUP BY Id )
with this query you also need to modify following line: