下面的sql怎么写?求助(酷狗的笔试题)

第一题我是这样写的,不知道对不对(不对的话还请大佬帮修改下),select songid from t_play as t1(select count(*) from t_play as t2 where t2.dt=t1.dt and t2.area=t1.area and t2.play_cnt<t1.play_cnt)<=2, 另外还有简单的写法吗?这个用group by能实现吗?
第二题不会写,求教!
全部评论
不会做,然后笔试没过
点赞 回复
分享
发布于 2018-05-19 18:28
1.select d.dt,a.area,d.songid from t_user a,(select * from t_user b,t_play c where b.area=a.area and  c.dt=d.dt and b.userid=c.userid order by c.play_cnt desc limit 0,3) e ,t_play  d group by d.dt,a.area having e.area=a.area and d.dt=e.dt and a.userid=d.userid ; 2 select  (select count(*) from  t_user, t_play where t_user.userid=t_play.userid and t_play.dt=20180502 and  t_user.userid  in (select * from t_user a, t_play b where a.userid=b.userid and b=20180501))/(select count(*)from t_user, t_play where t_user.userid=t_play.userid and t_play.dt=20180501)
点赞 回复
分享
发布于 2018-05-19 20:08
小红书
校招火热招聘中
官网直投

相关推荐

点赞 25 评论
分享
牛客网
牛客企业服务