Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return the largest value - max? 1

Status
Not open for further replies.

fiber0pti

ISP
Nov 22, 2000
96
US
How would I return the largest value of a few numbers?
I have categroies, subcategories and product IDs. I want to look up the Category and subcategory of the current product and then return the largest prod ID under those two.
Would I use max for this? It didn't seem like that would do the job.
 
Yes use Max,

like this
<CFQUERY name=&quot;name&quot; datasource=&quot;datasource)>
Select max(myField) as maxMine
From MyTable
</CFQUERY>

Hope that does it for you.
 
Hi fiber0pti,


The max() operator is used like: max(number1,number2), so not realy suited withing a cfquery (I think).

What you could do is:

cfquery...
select prod ID from tabelx
ORDER BY prod ID DESC

in the cfoutput you can select the biggest value by using:

<cfoutput query=&quot;name&quot; maxrows=&quot;1&quot;>#prod ID #</cfquery>

I hope this has helped you

Regards
Bram
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top