Subject General SQL question. What is the best way?
Author casibart
Hi,

I have a long running query that returns some patient names with the
tests and the prices like this.

PATIENT1, ROOM#, TEST NAME, COST
PATIENT2, ROOM#, TEST NAME, COST
PATIENT3, ROOM#, TEST NAME, COST
..


This is ok, but I also want to get the SUM of the COST FIELD. How can
I do it? Run the same long running query again with the "SUM"
function? Or is it better looping through the query results while
summing up the costs field? Or is it better using "group by" ?

Any ideas? Thank you.