以下是可用的aggregate functions用于 SQL
AVG() - Returns the average value
COUNT() - Returns the number of rows
FIRST() - Returns the first value
LAST() - Returns the last value
MAX() - Returns the largest value
MIN() - Returns the smallest value
SUM() - Returns the sum
我需要在日期时间字段上应用聚合函数吗?它没有在那里列出。 Max(), Min() 将不起作用。我需要的是
是否可以。我可以以某种方式实现它吗?
最佳答案
min() 和 max() 可以很好地处理日期
你也可以这样做
最新的
select top 1 *
from Table
order by SomeDate desc
最早的
select top 1 *
from Table
order by SomeDate
顺便说一句,SQL Server 没有 first() 和 last() 函数
关于sql - 使用 group by 聚合 sql 中的日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8360667/