 |
Talahaski Enchanter
Joined: 10 Oct 2000 Posts: 656 Location: USA
|
Posted: Sun Apr 11, 2004 9:39 pm
Database query - return max value. |
Does anybody know an easy way to query a numeric field in the database and return the max value for that field. Its possible that the Max could be zero or that there could be multiple records all with the same max value. For example 10 records could have the value of 2 and another 10 could have the value of 20.
For some additional information, my database name is AL, it has about 10 fields, one of which is called "Grouping". "Grouping" is the numeric field I want to find the max for. With this max value, I plan on doing other computations within the script.
Can anybody help me write something basic to get this value. I'm hoping there is a easier way than having to loop through every record.
Some possibilities I've considered which I'm not sure if they will work yet.
1. Loop through each record
2. Create a view sorted on this field and grab the first record - this might be the best way.
3. use %query to come up with some query that will contain the max. I'm not sure if this will work because the %query only looks at the where clause, what I really need is "select max(Grouping) from AL" |
|
|
|
 |
jessew Apprentice
Joined: 03 Mar 2003 Posts: 141
|
Posted: Sun Apr 11, 2004 9:57 pm |
If I understand correctly I think %dbmax(column[,view]) is what your looking for.
Jesse |
|
|
|
 |
Talahaski Enchanter
Joined: 10 Oct 2000 Posts: 656 Location: USA
|
Posted: Sun Apr 11, 2004 10:24 pm |
doh!
How did I miss that function!
Thanks a bunch. |
|
|
|
 |
|
|
|