I have a query which brings back a set of test scores for a student from a table that holds the scores for a whole class. Can I treat the $Result set that the query produces as a table and write things like:

$Result2="Select sum(testscores) AS ScoreTotal FROM $Result";

this could be rubbish I don't know?

I would like to do this as I want to first of all print all the data brought back from the first query and then process that data again to produce a total score for the student. I could just write a whole new query but would my suggestion be more efficient?