Reputation: 109
I'm been trying to find a example of how to get a max number in a column.What I want to do is, find the MAX number of a column in a TABLE_A, points(column). I want to output this MAX number for example
<cfoutput>
<tr>
<th><div align="right">#maxnumber#</div></th>
</tr>
</cfoutput>
Not sure if this is the way to output, But I just want one number(the MAX) , not an array of the column.
thanks for your help, new to ColdFusion.
Upvotes: 0
Views: 491
Reputation: 14333
You can do something like this to get the top X
from your query and then output them accordingly
<cfquery name="maxQuery">
SELECT TOP 2 points
FROM table_a
ORDER BY points DESC
</cfquery>
<cfoutput query="maxQuery">
#maxQuery.currentRow# - #maxQuery.points#<br>
</cfoutput>
Upvotes: 1
Reputation: 327
sql have a max and min function to get the maximum and minimum values for a column.You can use max function to get it like below.
select max(point) from TABLE_A
Upvotes: 0
Reputation: 661
you can do like below
select max(points) from TABLE_A
for getting second max number you can do like below
select max(point) as secondmax from TABLE_A where point<(select max(point) from TABLE_A)
Upvotes: 0