473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Finding the maximum value in a recordset column

How do I find the maximum value of a recordset column? I'd rather do it
this way than open a new recordset with Max(column).

Thanks in anticipation.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Oct 13 '05 #1
2 10327
Roger Withnell wrote:
How do I find the maximum value of a recordset column? I'd rather do
it this way than open a new recordset with Max(column).

Thanks in anticipation.


My preference would be to let the database (whatever it is) do this. If
using sql server, I would write a stored procedure that returned the
records, as well as returning the max(column) in an output parameter. If
Access, I would still make a second trip to the database.

However, what you can do is:

1. Optional but highly recommended: disconnect the recordset by setting its
ActiveConnection property to Nothing. This will allow you to close and
destroy your Connection object, freeing it up for another thread to use

2. Use the recordset's Sort property to sort by the column you wish to find
the max value of.

3. Move to the first or last record (depending on the sort direction you
used) and read the value.

HTH,
Bob barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 13 '05 #2
If you're looping through the recordset with your ASP code and then
showing the max after all that I'd suggest something similar to a
running sum ASP variable. But of course this would check each value and
only make a change if it's larger than the current value:

If objRS("TheValue") > MyMaxVariable Then
MyMaxVariable = objRS("TheValue")
End If

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips

<<
How do I find the maximum value of a recordset column? I'd rather do it
this way than open a new recordset with Max(column).

Thanks in anticipation.


*** Sent via Developersdex http://www.developersdex.com ***
Oct 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
9
by: Hamster | last post by:
I need to display data like this: CompanyName1 Company | Date| Transactions Count -- headers CompanyName1 | Date| 1 -- data CompanyName2 | Date| 5 -- data...
2
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
2
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the...
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
6
by: Dave Hopper | last post by:
Hi I am using the following SQL to retrieve a value in a list box using a unique ID held in the list box call cntID. The list box is used on an order form to list appointments that have been...
2
by: MyGreatProgramme | last post by:
I want to make a delete query that deletes all the items that are in the minorty. For example, in the field " Houses " there are 10 rows with value 1 , 3 rows with value 3 and 4 rows with...
15
by: timothytoe | last post by:
Situation: I have an array of objects. I want to find the maximum value of a given numeric value that exists in each of the objects. Suppose the array of objects is called "stat" and the numeric...
7
by: laredotornado | last post by:
Hi, I'm using PHP 5 with MySql 5. I have a MySQL InnoDB table with a column of type INTEGER UNSIGNED. Is there a constant in PHP to insert the maximum value possible into the column? The...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.