troubleshooting Question

How to calculate Min and Max using ASP

Avatar of alexisbr
alexisbr asked on
ASPVB Script
6 Comments2 Solutions644 ViewsLast Modified:
Hi!  Here's an example of the data I am working with.  The data is coming into ASP as a recordset from a SQL Server 2005 database view I wrote.  I want to get the avg, min and max values from the recordset.  The function avg works but not min and max so that tells me these functions do not exist in VBscript.  I cannot do the min / max functions in the view because I need to get date range input from the users on the web form to know the range of records to include.  Therefore, I need to calculate these values from the web page.

ID      Location      LocDate      LocMinutes
2      ABC      10/2/2007       7
4      ABC      12/3/2007      15
6      ABC      10/4/2007      10
Here's the query string I have set up on the web page.  If I remove the min and max parts below, the result works fine and I get the correct avg.  But I need the min and max values too.  Using the example data, I would want the recordset to return 7 as the min and 15 as the max.

select Location, avg(LocMinutes) as AvgMin, min(LocMinutes) as MinMinutes, max(LocMinutes) as MaxMinutes from vwMinutes

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros