我有一个带有日期列的5000条记录的表。
如何找到这些日期的平均值。我试过了AVG(datefield),但是说Operand data type datetime is invalidfor avg operator
AVG(datefield)
Operand data type datetime is invalidfor avg operator
如果只想平均日期:
SELECT CAST(AVG(CAST(datefield AS INT)) AS DATETIME) FROM dates;
如果您想考虑时间:
SELECT CAST(AVG(CAST(datefield AS FLOAT)) AS DATETIME) FROM dates;