I have a sample table with similar structure & data as shown below:
+------+---------+-------------+------------+
| S_ID | S_NAME | SUBJECT | MARK_VALUE |
+------+---------+-------------+------------+
| 1 | Stud | SUB_1 | 50 |
| 2 | Stud | SUB_2 | 60 |
| 3 | Stud | SUB_3 | 70 |
| 4 | Stud_1 | SUB_1 | 40 |
| 5 | Stud_1 | SUB_2 | 50 |
| 6 | Stud_2 | SUB_2 | 40 |
+------+---------+-------------+------------+
Table has consolidated mark of each student in all subjects each that student has appeared.
Please help me, to write a query to extract MAXIMUM mark obtained by each student (irrespective of subject/other students), as below:
Group by S_Name & Max(MARK_Value)
+------+---------+-------------+------------+
| S_ID | S_NAME | SUBJECT | MAX_MARK |
+------+---------+-------------+------------+
| 3 | Stud | SUB_3 | 70 |
| 5 | Stud_1 | SUB_2 | 50 |
| 6 | Stud_2 | SUB_2 | 40 |
+------+---------+-------------+------------+
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…