O
orne30712
I have a dataset that looks like this:
CREATE TABLE Scores ([ID] IDENTITY(1,1), StudentID INT, SubjectID INT, Score
FLOAT)
I want to get the lowest score and the subject for each student. So the
results will be
Student 1 MATH 50
Student 2 ENG 60
Student 3 MATH 55
Student 4 MATH 57
This query only gives me the StudentID and Max Score but not the SubjectID:
SELECT StudentID, MAX(Score)
FROM Scores
GROUP BY StudentID
If I add the SubjectID, it gives me every subject for every student:
SELECT StudentID, SubjectID, MAX(Score)
FROM Scores
GROUP BY StudentID, SubjectID
Any idea?
TIA
CREATE TABLE Scores ([ID] IDENTITY(1,1), StudentID INT, SubjectID INT, Score
FLOAT)
I want to get the lowest score and the subject for each student. So the
results will be
Student 1 MATH 50
Student 2 ENG 60
Student 3 MATH 55
Student 4 MATH 57
This query only gives me the StudentID and Max Score but not the SubjectID:
SELECT StudentID, MAX(Score)
FROM Scores
GROUP BY StudentID
If I add the SubjectID, it gives me every subject for every student:
SELECT StudentID, SubjectID, MAX(Score)
FROM Scores
GROUP BY StudentID, SubjectID
Any idea?
TIA