字节跳动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

相关推荐

07-22 11:53
门头沟学院 Java
终于有一个保底的offer了,但感觉是白菜价
北凝a:我想问问,提前批的offer 有问你啥时候到岗吗,如果你还想找其他的怎么办
点赞 评论 收藏
分享
来个厂收我吧:首先,市场侧求职我不是很懂。 但是,如果hr把这份简历给我,我会觉得求职人不适合做产品经理。 问题点: 1,简历的字体格式不统一,排版不尽如人意 2,重点不突出,建议参考star法则写个人经历 3,印尼官方货币名称为印度尼西亚卢比(IDR),且GMV690000印尼盾换算为305人民币,总成交额不高。 4,右上角的意向职位在发给其他公司时记得删除。 5,你所有的经历都是新媒体运营,但是你要投市场营销岗位,jd和简历不匹配,建议用AI+提示词,参照多个jd改一下经历内容。 修改建议: 1,统一字体(中文:思源黑体或微软雅黑,英文数字:time new romans),在word中通过表格进行排版(b站学) 2,校招个人经历权重:实习经历=创业经历(大创另算)>项目经历>实训经历>校园经历 3,请将项目经历时间顺序改为倒序,最新的放最上方。 4,求职方向不同,简历文字描述侧重点也需要不同。
点赞 评论 收藏
分享
评论
4
23
分享

创作者周榜

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