为什么这个 timestampdiff CASE 产生的 AVG 低于 WHEN?

Why does this timestampdiff CASE yield AVG lower than the WHEN?

我正在尝试通过源报告获取平均卸载日期,我有一个

select i.source,u.avgday from inst i
left join ( select u.app_uid,
  case 
    when timestampdiff(day,i.app_installed_datetime, u.timestamp) > 3
    then timestampdiff(day,i.app_installed_datetime, u.timestamp) 
   else null end as avgday
  from uninst u
  inner join inst i
  on i.app_uid = u.app_uid
) as u
on u.app_uid = i.app_uid
group by i.source

为什么我得到的 u.avgday 结果在 0.1-10 范围内?这不应该只有有值的 AVG,否则它是 Null 吗?

我认为您打算使用 AVG() 聚合函数,例如

  avg(case 
    when timestampdiff(day,i.app_installed_datetime, u.timestamp) > 3
    then timestampdiff(day,i.app_installed_datetime, u.timestamp) 
    end) as avgday