函数MAX()在WHERE子句中? [英] Function MAX() in WHERE clause?
本文介绍了函数MAX()在WHERE子句中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在WHERE子句中使用MAX() - 数学SQL函数吗?
我搜索了msdn论坛但没有得到任何使用MAX的工作查询WHERE子句中的()函数。
推荐答案
你不能直接在查询中使用它,因为它是一个聚合函数,意味着它对一组数据进行操作。那么在下面的sql的上下文中是max(年龄)?
You can't use it directly in a query because it is an aggregate function, meaning it does an operation on a set of data. So that is max(age) in the context of the sql below?
select * from person where age = max(age)
你可能意味着每个人的最大(年龄),但你必须具体。所以你可以做的是:
You probably mean the max(age) every person, but you must be specific on that. So what you can do is:
select * from person where age = (select max(age) from person)
希望上面有帮助。
祝你好运!
Hopefully the above helps.
Good luck!
指定组或聚合的条件,而不是 WHERE
声明,请使用 HAVING [ ^ ]。在那里你会找到一个例子。
To specify condition for a group or an aggregate, instead WHERE
statement, use HAVING[^]. There you'll find an example.
这篇关于函数MAX()在WHERE子句中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文