如何获得列中的最大数量?

2022-01-09 00:00:00 sql-server coldfusion

我一直在尝试查找如何在列中获取最大数量的示例.我想要做的是,在 TABLE_A 中找到一列的最大数量,点(列).例如,我想输出这个 MAX 数

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>

不确定这是否是输出方式,但我只想要一个数字(MAX),而不是列的数组.

Not sure if this is the way to output, But I just want one number(the MAX) , not an array of the column.

感谢您的帮助,ColdFusion 新手.

thanks for your help, new to ColdFusion.

推荐答案

你可以做这样的事情来从你的查询中获取顶部的 X,然后相应地输出它们

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>

相关文章