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

相关推荐

面试官很友善,&nbsp;对项目是刨根问底,对项目提出的缺点令人难堪,&nbsp;只能不断道歉。【面试问题】🎯&nbsp;**自我介绍与项目概览**1.&nbsp;请用&nbsp;3-4&nbsp;分钟做一个简洁的自我介绍,突出技术栈与研究方向即可,项目细节稍后展开。🧠&nbsp;**算法与代码能力**2.&nbsp;🔢&nbsp;给定一个整数数组,要求用&nbsp;O(n)&nbsp;时间、O(1)&nbsp;额外空间输出每个位置“除自身外所有元素的乘积”,请阐述思路并现场共享屏幕写出&nbsp;C++&nbsp;代码。3.&nbsp;📈&nbsp;给定一个整数数组,说明如何转化为最长非递减子序列问题,并现场共享屏幕写出&nbsp;C++&nbsp;代码。4.&nbsp;✂️&nbsp;针对最长非递减子序列的代码,请进一步压缩中间数组,真正做到&nbsp;O(1)&nbsp;额外空间。🔍&nbsp;**C/C++&nbsp;语言与内存管理**5.&nbsp;🆚&nbsp;请比较&nbsp;C++&nbsp;的&nbsp;new/delete&nbsp;与&nbsp;C&nbsp;的&nbsp;malloc/free&nbsp;的差异。6.&nbsp;🧩&nbsp;malloc/free&nbsp;的底层实现流程是什么?7.&nbsp;🔎&nbsp;实际项目中如何定位内存泄漏?如果没有&nbsp;Valgrind&nbsp;这类工具,如何实现内存泄漏检测器?8.&nbsp;💥&nbsp;描述一种“栈崩但栈顶代码无异常”的实际场景,并解释其成因与排查思路。🛰&nbsp;**xxx项目深挖**9.&nbsp;🌐&nbsp;概述你在观测平台项目中的角色、系统功能与业务价值。10.&nbsp;🧱&nbsp;画出数据流向图并说明11.&nbsp;⚖️&nbsp;为什么引入&nbsp;Redis&nbsp;Stream&nbsp;作为消息队列?削峰填谷的具体策略与降级方案是什么?如果消费速度持续低于生产速度,如何避免&nbsp;Redis&nbsp;内存爆掉?12.&nbsp;🗂️&nbsp;Redis&nbsp;Stream&nbsp;与&nbsp;List、Pub/Sub&nbsp;在消息队列场景下的优劣对比;ACK&nbsp;机制与消费组在内部是如何实现的?13.&nbsp;🔄&nbsp;如果去掉&nbsp;Redis&nbsp;Stream,&nbsp;直连数据库,你会如何重新设计流量控制与降级逻辑?问有没有看过&nbsp;redis&nbsp;源码?&nbsp;没看过为什么要用消息队列?&nbsp;&nbsp;面试官觉得完全没必要。只能不断道歉。了解过&nbsp;stream&nbsp;的实现吗?&nbsp;&nbsp;没有📁&nbsp;**xxx项目深挖**16.&nbsp;🔧&nbsp;为何不用&nbsp;HTTP/RPC?&nbsp;&nbsp;回答不了,&nbsp;实际上项目只是玩票。17.&nbsp;⏳&nbsp;当前实现中有没有通知机制?18.&nbsp;🌐&nbsp;如果改用&nbsp;RESTful&nbsp;API,用&nbsp;URL&nbsp;路径同样模拟层级结构,不是也可以吗?&nbsp;&nbsp;确实是。玩具项目,&nbsp;和生产实际不太相关。
查看19道真题和解析
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
4
23
分享

创作者周榜

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