Issue
Picture 1 is the table containing the data
Picture 2 is my command
Why is it only returning 1 row and not the same for all the subjectIDs? How do I make it return a row for each subjectID? Thanks
p.s Please keep things simple I need to do this with basic sql.
Solution
You are running an AVG
command. This will aggregate the results, since an average has to be run on multiple rows of data.
If you want to have it grouped in a different way, you can do this with a GROUP BY
clause. This will return a row for every distinct values for the column(s) specified in the GROUP BY
clause, with the calculated average and so on.
It would look similar to the following:
SELECT subjectid, AVG(result)
FROM Results
GROUP BY subjectid
Answered By - Kevin Van Ryckegem
Answer Checked By - Mary Flores (JavaFixing Volunteer)