mysql - Show marks and max marks in a single query -
for example have table
student | marks | 50 b | 60 c | 70 d | 80 what want
student | marks | maxmarks | 50 | 80 b | 60 | 80 c | 70 | 80 d | 80 | 80 i dont want use sub-queries/nested queries ..
you can in insane way without using subqueries:
select t.student, t.marks, max(t2.marks) maxmarks table t cross join table t2 group t.student, t.marks; here more sensible approach:
select t.student, t.marks, t2.maxmarks table t cross join (select max(t2.marks) maxmarks table t2) t2;
Comments
Post a Comment