SQL大厂笔试真题21

  1. avg(if语句)表示满足if条件的记录所占比例。
  2. concat( ,'%')将数值转换为字符串,并且添加%符号。

代码如下:

select department,

concat(round(avg(if(timestampdiff(minute,first_clockin,last_clockin)/60 > 9.5,1,0))*100,1),'%') as ratio from staff_tb join attendent_tb using(staff_id)

group by department

order by ratio desc

#牛客创作赏金赛#
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务