I am using a subquery to get the maximum id from a group.
The query is returning the correct
max(id)
from a group. But what I want as a result out of this table:id--------Name--------GROUP------------Result
1---------ABC----------A----------------Pass
2---------DEF----------B----------------FAIL
3---------GEH----------A----------------Pass
4---------ABC----------B----------------FAIL
5---------DEF----------A----------------FAIL
6---------GEH----------B----------------PASS
Is max id's of each group with a result of pass students only?
sorry for the kind of English used to describe my problem.
@Narayan-this will give the max(id) for each group for students with Result as Pass
SELECT MAX(ID)
FROM YourTable
WHERE Result = 'PASS'
GROUP BY `GROUP`;
0 comments:
Post a Comment