字节跳动SQL题目

字节跳动SQL面经,求大佬给题解
给出一个表T,有三列,分别为SNO,SUBJECT,SCORE
SNO SUBJECT SCORE
1001  语文          90
1001  数学          40
1002  语文          80
请写出这样的一个SQL,查询出语文成绩及格,数学成绩不及格的学生的SNO

#笔试题目#
全部评论
这种题目的话我觉得面试官一般是想考我们行列转换的内容,我面了一些都要考这个考点,所以我们可以先进行行列转换,再筛选就清晰很多了 select SNO from ( select SNO,   case SUBJECT when "语文" then SCORE end as chinese_score,  case SUBJECT when "数学" then SCORE end as maths_score from table1 ) where chinese_score >= 60 and maths_score <60
8 回复 分享
发布于 2021-03-10 08:15
https://www.nowcoder.com/ta/sql
2 回复 分享
发布于 2021-03-18 12:24
select unique SNO  from T where subject = '数学&(8804)#39; and score < 60 intersect select SNO from T  where subject = '语文&#39; and score >= 60;
1 回复 分享
发布于 2021-03-17 21:58
select a.sno from (select sno from t where subject='语文&(8803)#39; and score>=60) a inner join (select sno from t where subject='数学&(8804)#39; and score<60) b on a.sno=b.sno
9 回复 分享
发布于 2021-03-06 15:02
select SNO  from (select SNO, sum(case subject when'语文&(8803)#39; then score  else null end)  as chinese_score,  sum(case subject when'数学&(8804)#39; then score else null end)  as math_score  from t group by SNO ) as tt where tt.chinese_score>=60 and tt.math_score<60 ===================================== 如果是case subject ……else 0的话结果就会多了一个1002
2 回复 分享
发布于 2021-09-11 22:04
Select a.sno from (Select sno from t Where subject = '语文&(8803)#39; and score >= 60) a Inner join (select sno from t Where subject = '数学&(8804)#39; and score < 60) b On a.sno = b.sno
点赞 回复 分享
发布于 2022-05-21 22:05
SELECT SNO  FROM T  WHERE SUBJECT='语文&(8803)#39;  AND SCORE>=60  AND SNO IN (SELECT SNO FROM T WHERE SUBJECT='数学&(8804)#39; AND SCORE<60)
点赞 回复 分享
发布于 2021-12-18 17:46
select y.SNO from (            select *            from T            where subject='语文&(8803)#39; )  y join (            select *            from T            where subject='数学&(8804)#39; ) s on y.SNO =s.SNO where y.score>=60 and s.score <60; 这样可以吗?
点赞 回复 分享
发布于 2021-12-09 14:59
select SNO from T where (SUBJECT='语文&(8803)#39; and SCORE>=60) and (SUBJECT='数学&(8804)#39; and SCORE<60)
点赞 回复 分享
发布于 2021-12-06 12:14
select sno from T group by sno having sum(case subject when '语文&(8803)#39; then score else null end) >= 60 and sum(case subject when '数学&(8804)#39; then score else null end) < 60
点赞 回复 分享
发布于 2021-12-03 10:44
select a.sno from (select * from sqltest where subject = '语文&(8803)#39; and score >= 60) as a inner join (select * from sqltest where subject = '数学&(8804)#39; and score <60) as b on a.sno = b.sno select a.sno from (select sno, sum(case subject when '语文&(8803)#39; then score else null end) as chinese_score, sum(case subject when '数学&(8804)#39; then score else null end) as match_score from sqltest group by sno) as a where a.chinese_score >= 60 and a.match_score < 60
点赞 回复 分享
发布于 2021-12-03 10:15
select distinct SNO from T where SNO in (select SNO from T where subject='语文&(8803)#39; and score>=60) and SNO in  (select SNO from T where subject='数学&(8804)#39; and score<60)
点赞 回复 分享
发布于 2021-12-02 19:07
select stu_id,   sum(case course when "语文" then SCORE else 0 end) as chinese_score,  sum(case course when "数学" then SCORE else 0 end) as maths_score from exam group by stu_id having chinese_score >= 60 and maths_score <60
点赞 回复 分享
发布于 2021-08-06 13:07
select stu_id from exam where course = '语文&(8803)#39;  and score >= 60     and stu_id in ( select stu_id from exam where course = '数学&(8804)#39;  and score < 60)
点赞 回复 分享
发布于 2021-08-06 13:04
select SNO from T where subject='语文&(8803)#39; and score >=60 union slect SNO from T where subject='数学&#39; and score <60; 这样可以嘛?
点赞 回复 分享
发布于 2021-03-25 00:44

相关推荐

2025-12-31 18:42
复旦大学 Java
点赞 评论 收藏
分享
解zj:但是想想也挺好的 这么多天也面了挺多家公司 也越来越有感觉了 希望明天能有一个好的结果
投递字节跳动等公司8个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
2025-12-17 16:48
今天九点半到公司,我跟往常一样先扫了眼电脑,屁活儿没有。寻思着没事干,就去蹲了个厕所,回来摸出手机刷了会儿。结果老板刚好路过,拍了我一下说上班别玩手机,我吓得赶紧揣兜里。也就过了四十分钟吧,我的直属领导把我叫到小隔间,上来就给我一句:“你玩手机这事儿把老板惹毛了,说白了,你可以重新找工作了,等下&nbsp;HR&nbsp;会来跟你谈。”&nbsp;我当时脑子直接宕机,一句话都没憋出来。后面&nbsp;HR&nbsp;找我谈话,直属领导也在旁边。HR&nbsp;说我这毛病不是一次两次了,属于屡教不改,不光上班玩手机,还用公司电脑看论文、弄学校的事儿。我当时人都傻了,上班摸鱼是不对,可我都是闲得发慌的时候才摸啊!而且玩手机这事儿,从来没人跟我说过后果这么严重,更没人告诉我在公司学个习也算犯错!连一次口头提醒都没有,哪儿来的屡教不改啊?更让我膈应的是,昨天部门刚开了会,说四个实习生里留一个转正,让大家好好表现。结果今天我就因为玩手机被开了。但搞笑的是,开会前直属领导就把我叫去小会议室,明明白白告诉我:“转正这事儿你就别想了,你的学历达不到我们部门要求,当初招你进来也没打算给你这个机会。”合着我没入贵厂的眼是吧?可我都已经被排除在转正名单外了,摸个鱼至于直接把我开了吗?真的太离谱了!
rush$0522:转正名单没进,大概率本来就没打算留你
摸鱼被leader发现了...
点赞 评论 收藏
分享
评论
4
23
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务