标签: sql date
我想根据Factor1值为A的Factor2和Facort3之间的天数来计算日期的平均值。
我该怎么办?
答案 0 :(得分:3)
select avg(DATEDIFF(DAY,Factor2,Factor3)) from [TestingTable] where Factor1='A'
我已经计算了Factor2和Factor 3之间的差,其中Factor1是A,然后求出该列的平均值。
结果必须为“ 3”
它在SQL中: 1- DATEDIFF(datepart,startdate,enddate)
2-AVG([ALL | DISTINCT]表达式)
3- datepart:可以是日,月,年...等