select b.unitCode,b.unit,AVG(b.age*1.0) avgAge from (select ((2015-SUBSTRING(birthday,0,5))*12+(3-SUBSTRING(birthday,5,2)))/12 as age
,a.* from TRT_CADRES a) b where unit is not null group by b.unitCode,b.unit
AVG(b.age*1.0)
select case when avg(colname*1.0)=cast(avg(colname*1.0) as int) then avg(colname*1.0) else cast(avg(colname*1.0) as decimal(9,1)) end
,a.* from TRT_CADRES a) b where unit is not null group by b.unitCode,b.unit
AVG(b.age*1.0)
select case when avg(colname*1.0)=cast(avg(colname*1.0) as int) then avg(colname*1.0) else cast(avg(colname*1.0) as decimal(9,1)) end
本文介绍了如何使用SQL查询来计算并展示特定单位下的员工年龄平均值,通过分组和聚合操作,实现了数据的精细化分析。
5308

被折叠的 条评论
为什么被折叠?



