I am understanding that for your results you want to see who (Names) has the highest TotalScore for all classes. If my understanding is correct, here is one way you could structure that SPL. I us...
See more...
I am understanding that for your results you want to see who (Names) has the highest TotalScore for all classes. If my understanding is correct, here is one way you could structure that SPL. I used makeresults to recreate your example table of data (thanks - that table helped me see what you're looking at): | makeresults format=csv data="Class,Name,Subject,TotalScore,Score1,Score2,Score3
ClassA,Name1, Math, 170, 60 ,40 ,70
ClassA,Name1, English ,195, 85, 60, 50
ClassA,Name2, Math, 175, 50, 60, 65
ClassA,Name2, English ,240, 80, 90, 70
ClassA,Name3, Math, 170, 40, 60 ,70
ClassA,Name3, English ,230, 55, 95, 80"
| eventstats max(TotalScore) as max_TotalScore by Class, Subject
| where TotalScore=max_TotalScore
| table Class Name, Subject, TotalScore, Score1, Score2, Score3 I used the eventstats command to determine the highest scores by Class and Subject. Essentially this will add a new field on each row called max_TotalScore. I then use where to only keep the rows (i.e. Names) for the ones where the TotalScore equals this max_TotalScore - that means this person is the one with the highest score. Results: