Home » RDBMS Server » Server Administration » : How to calculating the max,min,avg of a column from a given query?
: How to calculating the max,min,avg of a column from a given query? [message #371971] Thu, 28 December 2000 09:31 Go to next message
Mark
Messages: 284
Registered: July 1998
Senior Member
I want to calculate the maximum, minimum, and average of a subset of a column. My psuedo query would be:
select time_stamp, Temperature from foo where time_stamp >= to_date('122700:10:05') and time_stamp <= to_date('122700:10:07');
Here is what I would like to see, with the max,min,avg at the bottom.
TIME_STAMP OSA_TEMPERATURE
---------- ---------------
122700:10:05 65.1
122700:10:06 65.2
122700:10:07 65.0
------------
maximum 65.2
minimum 65.0
average 65.1

How can I have the query display the max, min and avg at the end of the report? What do I need to add to the query to get this information?
Re: : How to calculating the max,min,avg of a column from a given query? [message #371973 is a reply to message #371971] Thu, 28 December 2000 12:33 Go to previous messageGo to next message
Tuner
Messages: 2
Registered: December 2000
Junior Member
select max(Temperature) max_temp,
min(Temperature) min_temp,
Avg(Temperature) avg_temp,
from foo
where time_stamp >= to_date('122700:10:05','mmddyy:hh:mi')
and time_stamp <= to_date('122700:10:07','mmddyy:hh:mi');
Re: : How to calculating the max,min,avg of a column from a given query? [message #371979 is a reply to message #371973] Fri, 29 December 2000 09:24 Go to previous message
me
Messages: 66
Registered: August 2000
Member
it won't make any difference to your results butI would also change the where statement to between:

where time_stamp between to_date('122700:10:05','mmddyy:hh:mi')
and to_date('122700:10:07','mmddyy:hh:mi');
Previous Topic: 'where' condition...
Next Topic: how to pass variables into a sql script
Goto Forum:
  


Current Time: Fri May 17 01:47:31 CDT 2024