当前位置: 首页 > news >正文

怎么做干果网站/合肥网络推广营销

怎么做干果网站,合肥网络推广营销,红酒论坛网站建设,济南手机网站开发公司作业需要数据表SQL语句已给 1. 查询" 01 "课程比" 02 "课程成绩高的学生的信息及课程分数 select * from Student RIGHT JOIN (select t1.SId, class1, class2 from(select SId, score as class1 from sc where sc.CId 01)as t1, (select SId, score as …

作业需要数据表SQL语句已给

986efecee4084e6f8b44c13030f9f398.png

 1. 查询" 01 "课程比" 02 "课程成绩高的学生的信息及课程分数

select * from Student RIGHT JOIN (select t1.SId, class1, class2 from(select SId, score as class1 from sc where sc.CId = '01')as t1, (select SId, score as class2 from sc where sc.CId = '02')as t2where t1.SId = t2.SId AND t1.class1 > t2.class2
)r on Student.SId = r.SId;

 1.1 查询同时存在" 01 "课程和" 02 "课程的情况

select * from (select * from sc where sc.CId = '01') as t1, (select * from sc where sc.CId = '02') as t2
where t1.SId = t2.SId;

1.2 查询存在" 01 "课程但可能不存在" 02 "课程的情况(不存在时显示为 null )

select * from 
(select * from sc where sc.CId = '01') as t1
left join 
(select * from sc where sc.CId = '02') as t2
on t1.SId = t2.SId;

1.3 查询不存在" 01 "课程但存在" 02 "课程的情况

select * from sc
where sc.SId not in (select SId from sc where sc.CId = '01'
) and sc.CId= '02';

2.查询平均成绩大于等于 60 分的同学的学生编号和学生姓名和平均成绩

select student.SId,sname,ss from student,(select SId, AVG(score) as ss from sc  group by SId having AVG(score)> 60)r where student.sid = r.sid;

3.查询在 SC 表存在成绩的学生信息

select distinct student.*
from student,sc
where student.SId=sc.SId

4.查询所有同学的学生编号、学生姓名、选课总数、所有课程的总成绩(没成绩的显示为 null )

select s.sid, s.sname,r.coursenumber,r.scoresum
from ((select student.sid,student.sname from student)s left join (select sc.sid, sum(sc.score) as scoresum, count(sc.cid) as coursenumber from sc group by sc.sid)r on s.sid = r.sid);

 

4.1 查有成绩的学生信息

select * from student where exists (select sc.sid from sc where student.sid = sc.sid);

5.查询「李」姓老师的数量

select count(*) from teacher where tname like '李%';

6.查询学过「张三」老师授课的同学的信息

select student.* from student,teacher,course,sc
where student.sid = sc.sid and course.cid=sc.cid and course.tid = teacher.tid and tname = '张三';

7.查询没有学全所有课程的同学的信息

select * from student
where student.sid not in (select sc.sid from scgroup by sc.sidhaving count(sc.cid)= (select count(cid) from course));

8.查询至少有一门课与学号为" 01 "的同学所学相同的同学的信

select * from student 
where student.sid in (select sc.sid from sc where sc.cid in(select sc.cid from sc where sc.sid = '01'));

9.查询和" 01 "号的同学学习的课程 完全相同的其他同学的信息

select * from student where sid in(
select a.sid from (select sid,group_concat(cid order by cid) as courses 
from sc group by sid) as a
inner join (select sid,group_concat(cid order by cid) as courses 
from sc group by sid having sid='01') as b
on a.sid != 1 and a.courses = b.courses);

10.查询没学过"张三"老师讲授的任一门课程的学生姓名

select * from student
where student.sid not in(select sc.sid from sc,course,teacher wheresc.cid = course.cidand course.tid = teacher.tidand teacher.tname= "张三");

11.查询两门及其以上不及格课程的同学的学号,姓名及其平均成绩

select student.sid, student.Sname,b.avg
from student right join
(select sid, AVG(score) as avg from scwhere sid in (select sid from sc where score<60 group by sid having count(score)>1)group by sid) b on student.sid=b.sid;

12.检索" 01 "课程分数小于 60,按分数降序排列的学生信息

select student.*, sc.score from student, sc
where student.sid = sc.sid
and sc.score < 60
and cid = "01"
order by sc.score desc;

13.按平均成绩从高到低显示所有学生的所有课程的成绩以及平均成绩

select *  from sc 
left join (select sid,avg(score) as avscore from sc group by sid)r 
on sc.sid = r.sid
order by avscore desc;

14.查询各科成绩最高分、最低分和平均分:

以如下形式显示:课程 ID,课程 name,最高分,最低分,平均分,及格率,中等率,优良率,优秀率;及格为>=60,中等为:70-80,优良为:80-90,优秀为:>=90;要求输出课程号和选修人数,查询结果按人数降序排列,若人数相同,按课程号升序排列

select 
sc.CId ,
max(sc.score)as 最高分,
min(sc.score)as 最低分,
AVG(sc.score)as 平均分,
count(*)as 选修人数,
sum(case when sc.score>=60 then 1 else 0 end )/count(*)as 及格率,
sum(case when sc.score>=70 and sc.score<80 then 1 else 0 end )/count(*)as 中等率,
sum(case when sc.score>=80 and sc.score<90 then 1 else 0 end )/count(*)as 优良率,
sum(case when sc.score>=90 then 1 else 0 end )/count(*)as 优秀率 
from sc
GROUP BY sc.CId
ORDER BY count(*)DESC, sc.CId ASC

15.按各科成绩进行排序,并显示排名, Score 重复时保留名次空缺

SELECT *,row_number() over (PARTITION BY cid ORDER BY score DESC) AS '排名'FROM sc;

15.1 按各科成绩进行排序,并显示排名, Score 重复时合并名次

select *,
case when @sco=score then @rank else @rank:=@rank+1 end as rn,
@sco:=score
from sc,(select @rank:=0,@sco:=NULL) t
order by score desc;

16.查询学生的总成绩,并进行排名,总分重复时保留名次空缺

select a.*,
@rank:=if(@sco=scos,'',@rank+1) as rn,
@sco:=scos
from
(select sid,sum(score) as scos from sc
group by sid order by scos desc) a,
(select @rank:=0,@sco:=NULL) b;

16.1 查询学生的总成绩,并进行排名,总分重复时不保留名次空缺

select a.*,
@rank:=if(@sco=scos,@rank,@rank+1) as rn,
@sco:=scos
from
(select sid,sum(score) as scos from sc
group by sid order by scos desc) a,
(select @rank:=0,@sco:=NULL) b;

17.统计各科成绩各分数段人数:课程编号,课程名称,[100-85],[85-70],[70-60],[60-0] 及所占百分比

select course.cname, course.cid,
sum(case when sc.score<=100 and sc.score>85 then 1 else 0 end) as "[100-85]",
sum(case when sc.score<=85 and sc.score>70 then 1 else 0 end) as "[85-70]",
sum(case when sc.score<=70 and sc.score>60 then 1 else 0 end) as "[70-60]",
sum(case when sc.score<=60 and sc.score>0 then 1 else 0 end) as "[60-0]"
from sc left join course on sc.cid = course.cid group by sc.cid;

18.查询各科成绩前三名的记录

select * from sc
where (
select count(*) from sc as a 
where sc.cid = a.cid and sc.score<a.score 
)< 3 order by cid asc, sc.score desc;

19.查询每门课程被选修的学生数

select cid, count(sid) from sc  group by cid;

20.查询出只选修两门课程的学生学号和姓名

select student.SId,student.Sname
from sc,student
where student.SId=sc.SId  
group by sc.SId
having count(*)=2;

21.查询男生、女生人数

select ssex, count(*) from student group by ssex;

22.查询名字中含有「风」字的学生信息

select * from student  where student.Sname like '%风%';

23.查询同名同性学生名单,并统计同名人数

select sname, count(*) from student group by sname having count(*)>1;

24.查询 1990 年出生的学生名单

select * from student where YEAR(student.Sage)=1990;

25.查询每门课程的平均成绩,结果按平均成绩降序排列,平均成绩相同时,按课程编号升序排列

select sc.cid, course.cname, AVG(SC.SCORE) as average from sc, course
where sc.cid = course.cid group by sc.cid order by average desc,cid asc;

26.查询平均成绩大于等于 85 的所有学生的学号、姓名和平均成绩

select student.sid, student.sname, AVG(sc.score) as aver from student, sc
where student.sid = sc.sid group by sc.sid having aver > 85;

27.查询课程名称为「数学」,且分数低于 60 的学生姓名和分数

select student.sname, sc.score from student, sc, course
where student.sid = sc.sid and course.cid = sc.cid and course.cname = "数学" and sc.score < 60;

28.查询所有学生的课程及分数情况(存在学生没成绩,没选课的情况)

select student.sname, cid, score from student left join sc on student.sid = sc.sid;

29.查询任何一门课程成绩在 70 分以上的姓名、课程名称和分数

select student.sname, course.cname,sc.score from student,course,sc
where sc.score>70 and student.sid = sc.sid and sc.cid = course.cid;

30.查询不及格的课程

select distinct sc.CId from sc where sc.score <60;

31.查询课程编号为 01 且课程成绩在 80 分以上的学生的学号和姓名

select student.sid,student.sname from student,sc
where cid="01" and score>=80 and student.sid = sc.sid;

32.求每门课程的学生人数

select sc.cid,count(*) as 学生人数 from sc group by sc.cid;

33.成绩不重复,查询选修「张三」老师所授课程的学生中,成绩最高的学生信息及其成绩

select student.*, sc.score, sc.cid from student, teacher, course,sc 
where teacher.tid = course.tid
and sc.sid = student.sid
and sc.cid = course.cid
and teacher.tname = "张三"
order by score desc
limit 1;

34.成绩有重复的情况下,查询选修「张三」老师所授课程的学生中,成绩最高的学生信息及其成绩

select student.*, sc.score, sc.cid from student, teacher, course,sc 
where teacher.tid = course.tid
and sc.sid = student.sid
and sc.cid = course.cid
and teacher.tname = "张三"
and sc.score = (select Max(sc.score) from sc,student, teacher, coursewhere teacher.tid = course.tidand sc.sid = student.sidand sc.cid = course.cidand teacher.tname = "张三"
);

35.查询不同课程成绩相同的学生的学生编号、课程编号、学生成绩

select  a.cid, a.sid,  a.score from sc as a
inner join 
sc as b
on a.sid = b.sid
and a.cid != b.cid
and a.score = b.score
group by cid, sid;

36.查询每门功成绩最好的前两名

select a.sid,a.cid,a.score from sc as a left join sc as b 
on a.cid = b.cid and a.score<b.score
group by a.cid, a.sid having count(b.cid)<2 order by a.cid;

37.统计每门课程的学生选修人数(超过 5 人的课程才统计)。

select sc.cid, count(sid) as cc from sc group by cid having cc >5;

38.检索至少选修两门课程的学生学号

select sid, count(cid) as cc from sc group by sid having cc>=2;

39.查询选修了全部课程的学生信息

select student.* from sc ,student where sc.SId=student.SId group by sc.SId having count(*) = (select distinct count(*) from course )

40.查询各学生的年龄,只按年份来算

select *, (year(now()) - year(sage)) as age from student;

41.按照出生日期来算,当前月日 < 出生年月的月日则,年龄减一

select *, timestampdiff(YEAR,sage,NOW()) as age from student;

42.查询本周过生日的学生

select * from student where WEEKOFYEAR(student.Sage)=WEEKOFYEAR(CURDATE());

43.查询下周过生日的学生

select * from student where WEEKOFYEAR(student.Sage)=WEEKOFYEAR(CURDATE())+1;

44.查询本月过生日的学生

select * from student where MONTH(student.Sage)=MONTH(CURDATE());

45.查询下月过生日的学生

select * from student where MONTH(student.Sage)=MONTH(CURDATE())+1;

 

 

相关文章:

MySQL45道练习题

作业需要数据表SQL语句已给 1. 查询" 01 "课程比" 02 "课程成绩高的学生的信息及课程分数 select * from Student RIGHT JOIN (select t1.SId, class1, class2 from(select SId, score as class1 from sc where sc.CId 01)as t1, (select SId, score as …...

HTML5和CSS3的新特性

HTML5的新特性主要是针对于以前的不足&#xff0c;增加了一些新的标签、新的表单和新的表单属性等 1&#xff0c;HTML5新增的语义化标签 <header> 头部标签 <nav> 导航标签 <article> …...

【MySQL】表列数和行大小限制详解

目录 限制维度 列数量限制 表的最大行大小 单个列的存储要求 存储引擎的附加限制 功能键部分 行容量限制 MySQL表的内部实现 InnoDB表的最大行大小 超出InnoDB最大行大小的处理 不同存储格式的影响 限制示例 行大小限制示例 InnoDB下 MyISAM下 InnoDB变长情况示…...

算法基础学习|双指针算法

双指针算法 代码模板 for (int i 0, j 0; i < n; i ){while (j < i && check(i, j)) j ;// 具体问题的逻辑 } 常见问题分类&#xff1a;(1) 对于一个序列&#xff0c;用两个指针维护一段区间(2) 对于两个序列&#xff0c;维护某种次序&#xff0c;比如归并…...

4.远程登录服务

目录 1. 简介 1.1. 概念 1.2. 功能: 1.3. 分类 1.3.1. 文字接口: 1.3.2. 图形接口&#xff1a; 1.4. 文字接口连接服务器: 2. 连接加密技术简介 2.1. 密钥解析&#xff1a; 3. SSH工作过程&#xff1a; 3.1. 版本协商阶段 3.2. 密钥和算法协商阶段 3.3. 认证阶段(两…...

代码随想录算法训练营第二十九天| 491.递增子序列、46.全排列、47.全排列 II

491.递增子序列 题目链接&#xff1a;力扣&#xff08;LeetCode&#xff09;官网 - 全球极客挚爱的技术成长平台 解题思路&#xff1a;同层相同元素要跳过 java&#xff1a; class Solution {List<List<Integer>> resultnew ArrayList<>();List<Integ…...

基于若依的ruoyi-nbcio流程管理系统一种简单的动态表单模拟测试实现(五)

更多ruoyi-nbcio功能请看演示系统 gitee源代码地址 前后端代码&#xff1a; https://gitee.com/nbacheng/ruoyi-nbcio 演示地址&#xff1a;RuoYi-Nbcio后台管理系统 更多nbcio-boot功能请看演示系统 gitee源代码地址 后端代码&#xff1a; https://gitee.com/nbacheng/n…...

多场景建模:阿里多场景多任务元学习方法M2M

multi-scenario multi-task meta learning approach (M2M) 背景 广告领域大部分是针对用户建模的&#xff0c;像点击率预估&#xff0c;很少有针对广告主需求建模&#xff08;广告消耗预估、活跃率/流失率预估、广告曝光量预估&#xff09;&#xff0c;广告的类型较多&#x…...

仿真机器人-深度学习CV和激光雷达感知(项目2)day03【机器人简介与ROS基础】

文章目录 前言机器人简介机器人应用与前景机器人形态机器人的构成 ROS基础ROS的作用和特点ROS的运行机制ROS常用命令 前言 &#x1f4ab;你好&#xff0c;我是辰chen&#xff0c;本文旨在准备考研复试或就业 &#x1f4ab;本文内容是我为复试准备的第二个项目 &#x1f4ab;欢迎…...

【多商户开源-BSD- Fecmall 电商平台】

关于Fecmall Fecmall 关于&#xff0c;Fecmall介绍 Fecbbc开源BSD多商户系统&#xff0c;真正开源&#xff0c;商用免费授权的多商户系统 Fecmall系统简介&#xff1a; 全称为Fancy ECommerce Shop&#xff0c; 着重于电商架构的研发优化&#xff0c;全新定义商城的架构体系&…...

2023春秋杯冬季赛 --- Crypto wp

文章目录 前言Cryptonot_wiener 前言 比赛没打&#xff0c;赛后随便做一下题目 Crypto not_wiener task.py: from Crypto.Util.number import * from gmpy2 import * import random, os from hashlib import sha1 from random import randrange flagb x bytes_to_long(f…...

ImageMagick使用手册

ImageMagick使用手册 文章目录 ImageMagick使用手册ImageMagick是什么指令总结1.查看版本2.官网验证指令解读3.svg转png4.png转ico5.将指定文件夹中的所有PNG图像转换为ICO图标 本教程持续更新&#xff0c;我学到多少就更新多少。关于ffmpeg如何安装可以看上一篇博客win系统环境…...

嵌入式培训机构四个月实训课程笔记(完整版)-C++和QT编程第五天-Qt编程技巧若干解答(物联技术666)

链接&#xff1a;https://pan.baidu.com/s/1-u7GvgM0TLuiy9z7LYQ80Q?pwd1688 提取码&#xff1a;1688 QT在Windows下制作图表 QT是跨平台的程序设计库&#xff0c;在windows下的程序往往想要有一个好看的图标&#xff0c;方法如下&#xff1a; 1.准备个ICO图标。例如&…...

【蓝桥杯选拔赛真题59】python小写字母 第十五届青少年组蓝桥杯python 选拔赛比赛真题解析

目录 python小写字母 一、题目要求 1、编程实现 2、输入输出...

代码随想录算法训练营Day37|738.单调递增的数字、贪心算法总结

目录 738.单调递增的数字 方法一&#xff1a;暴力解法 方法二&#xff1a;贪心解法 贪心算法总结 738.单调递增的数字 题目链接 文章链接 方法一&#xff1a;暴力解法 class Solution { private:// 各位递增判断函数bool checkNum(int num) {int max 10;while (num) {int …...

笔记-影响力-对比,互惠,赌徒原理

笔记 From 《影响力》 目录 C1 影响力的武器 C2:互惠 C3 承诺和一致 C4:社会认同 C5:喜好 C6:权威 C7:稀缺 Ankie的笔记&#xff1a;对比&#xff0c;互惠&#xff0c;赌徒原理 C1 影响力的武器 人类在认知方面有个原理&#xff0c;叫“对比原理”。 假设有人走进一…...

PIL、cv2、numpy,和pytorch(torch)之间的转换

在图像处理和深度学习中&#xff0c;经常需要在PIL&#xff08;Python Imaging Library&#xff09;、OpenCV&#xff08;cv2&#xff09;、NumPy和PyTorch之间进行图像数据的转换。下面是这些库之间常见的转换方法。 1. PIL和numpy之间的转换 import numpy as np from PIL i…...

Java面试题50道

文章目录 1.谈谈你对Spring的理解2.Spring的常用注解有哪些3.Spring中的bean线程安全吗4.Spring中的设计模式有哪些5.Spring事务传播行为有几种6.Spring是怎么解决循环依赖的7.SpringBoot自动配置原理8.SpringBoot配置文件类型以及加载顺序9.SpringCloud的常用组件有哪些10.说一…...

电脑怎么剪辑视频?这些软件不可错过

电脑怎么剪辑视频&#xff1f;随着视频时代的到来&#xff0c;越来越多的人开始涉足视频制作。从Vlog到短片&#xff0c;再到专业级的影视作品&#xff0c;视频已经成为了我们生活中不可或缺的一部分。那么&#xff0c;如何才能快速掌握视频剪辑技巧&#xff0c;制作出令人惊叹…...

HBase学习七:Compaction

1、简介 Compaction是从一个Region的一个Store中选择部分HFile文件进行合并。其目的为了减少 HFile 的个数跟清理掉过期和删除的数据。 合并原理是,先从这些待合并的数据文件中依次读出KeyValue,再由小到大排序后写入一个新的文件。之后,这个新生成的文件就会取代之前已合…...

MySQL定期整理磁盘碎片

MySQL定期整理磁盘碎片&#xff1a;提升数据库性能的终极指南 MySQL作为一个强大的关系型数据库管理系统&#xff0c;在长时间运行后可能会产生磁盘碎片&#xff0c;影响数据库性能。本博客将深入讨论如何定期整理MySQL磁盘碎片&#xff0c;以确保数据库的高效运行。我们将介绍…...

【centos7安装docker】

背景&#xff1a; 学习docker&#xff0c;我是想做一个隔离环境&#xff0c;并且部署的话&#xff0c;希望实现自动化&#xff0c;不为安装软件而烦恼&#xff0c;保证每个人的环境一致。 2C4G内存 50G磁盘的虚拟机事先已经准备完毕。 1.查看下centos版本&#xff0c;docker要…...

四、Flask学习之JavaScript

四、Flask学习之JavaScript JavaScript&#xff0c;作为一种前端脚本语言&#xff0c;赋予网页生动的交互性和动态性。通过它&#xff0c;开发者能够操作DOM&#xff08;文档对象模型&#xff09;实现页面元素的动态改变、响应用户事件&#xff0c;并借助AJAX技术实现异步数据…...

IO 专题

使用try-with-resources语句块&#xff0c;可以自动关闭InputStream [实践总结] FileIUtils 共通方法最佳实践 [实践总结] java 获取在不同系统下的换行符 [实践总结] StreamIUtils 共通方法最佳实践 斜杠“/“和反斜杠“\“的区别 路径中“./”、“…/”、“/”代表的含义…...

MySql索引事务讲解和(经典面试题)

&#x1f3a5; 个人主页&#xff1a;Dikz12&#x1f525;个人专栏&#xff1a;MySql&#x1f4d5;格言&#xff1a;那些在暗处执拗生长的花&#xff0c;终有一日会馥郁传香欢迎大家&#x1f44d;点赞✍评论⭐收藏 目录 索引 概念 索引的相关操作 索引内部数据结构 事务 为…...

《微信小程序开发从入门到实战》学习九十一

7.1 视图容器组件 7.1.2 scroll-view组件 scroll-view组件时是滚动的视图容器&#xff0c;可在竖直方向或水平方向上滚动&#xff0c;展示超出屏幕高度或宽度的内容。 使用竖直方向滚动时&#xff0c;需要通过wxss的height样式给scroll-view设置一个固定高度&#xff0c;超出…...

【立创EDA-PCB设计基础】6.布线铺铜实战及细节详解

前言&#xff1a;本文进行布线铺铜实战及详解布线铺铜的细节 在本专栏中【立创EDA-PCB设计基础】前面完成了布线铺铜前的设计规则的设置&#xff0c;接下来进行布线 布局原则是模块化布局&#xff08;优先布局好确定位置的器件&#xff0c;例如排针、接口、主控芯片&#xff…...

Node.JS CreateWriteStream(大容量写入文件流优化)

Why I Need Node.JS Stream 如果你的程序收到以下错误&#xff0c;或者需要大容量写入很多内容(几十几百MB甚至GB级别)&#xff0c;则必须使用Stream文件流甚至更高级的技术。 Error: EMFILE, too many open files 业务场景&#xff0c;我们有一个IntradayMissingRecord的补…...

安卓开发之自动缩放布局

AutoScalingLayout 适用于 Android 的自动缩放布局。 替换布局&#xff1a; 我们只需要替换根布局所需的自动缩放&#xff0c;子布局也将实现自动缩放。 原始布局AutoScalingLayout相对布局ASRelativeLayout线性布局ASLinearLayoutFrameLayout&#xff08;框架布局&#xff…...

DDD系列 - 第9讲 实体、值对象

目录 引言一、实体1.1 数据库实体1.2 数据库实体 vs. DDD实体1.3 DDD实体的本质及其识别规则1.4 代码中如何定义实体二 、值对象2.1 值对象 vs. 附属属性2.2 值对象 vs. 实体2.3 代码中如何定义值对象2.4 何时使用值对象引言 之前我在《DDD系列 - 第4讲 从架构师的角度看待DDD…...