如何创办一个赚钱的网站/房产网站模板
创建表
create table Student
( Sno varchar(20) primary key,Sname varchar(20) UNIQUE,Ssex varchar(2),Sbirthday date,class varchar(20)
)create table Course
( Cno varchar(20) primary key,Cname varchar(20) UNIQUE,Tno varchar(20)
)create table Score
( Sno varchar(20),Cno varchar(20),Degree smallint,primary key(Sno,Cno),FOREIGN KEY (Cno) references Course(Cno),FOREIGN KEY (Sno) references Student(Sno)
)create table Teacher
( Tno varchar(20) primary key,Tname varchar(20) UNIQUE,Tsex varchar(20),Tbirthday date,Prof varchar(20),Depart varchar(20)
)
INSERT INTO Student (Sno,Sname,Ssex,Sbirthday,class)VALUES('108','曾华','男','1997/09/01','95033'),('105','匡明','男','1995/10/02','95031'),('107','王丽','女','1996/01/23','95033'),('101','李军','男','1996/02/20','95033'),('109','王芳','女','1995/02/10','95031'),('103','陆君','男','1994/06/03','95031'); INSERT INTO Course(Cno,Cname,Tno)VALUES('3-105','计算机导论','825'),('3-245','操作系统','804'),('6-166','数字电路','856'),('9-888','高等数学','831') ;INSERT INTO Score(Sno,Cno,Degree)VALUES('103','3-245',86),('105','3-245',75),('109','3-245',68),('103','3-105',92),('105','3-105',88),('109','3-105',76),('101','3-105',64),('107','3-105',91),('108','3-105',78),('101','6-166',85),('107','6-166',79),('108','6-166',81);INSERT INTO Teacher (Tno,Tname,Tsex,Tbirthday,prof,Depart)VALUES('804','李城','男','1980-12-02','副教授','计算机系'),('856','张旭','男','1977-03-12','讲师','电子工程系'),('825','王萍','女','1992-05-05','助教','计算机系'),('831','刘冰','女','1993-01-20','助教','电子工程系');
--1、 查询Student表中的所有记录的Sname、Ssex和Class列。
select Sname,Ssex,Class from Student
--2、 查询教师所有的单位即不重复的Depart列。
--3、 查询Student表的所有记录。
select * from Student
--4、 查询Score表中成绩在60到80之间的所有记录。
select * from Score where Degree between 60 and 80
--5、 查询Score表中成绩为85,86或88的记录。
select *from Score where Degree in(85,86,88)
--6、 查询Student表中“95031”班或性别为“女”的同学记录。
select * from Student where Class=95031 or Ssex='女'
--7、 以Class降序查询Student表的所有记录。
select * from Student order by Class DESC
--8、 以Cno升序、Degree降序查询Score表的所有记录。
select *from Score order by Cno,Degree DESC
--9、 查询“95031”班的学生人数。
select count(Class) from Student where Class=95031
--10、 查询Score表中的最高分的学生学号和课程号。(子查询或者排序)
select Sno,Cno
from Score
where Degree =(select max(degree) from score)
--11、 查询每门课的平均成绩。
select Cno,AVG(Degree)
from Score
where Cno='3-105' group by Cno
--12、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。
select AVG(Degree)
from Score
where Cno=(
select Cno
from Score
group by Cno
having count(Cno)>=5
)
and Cno like '3%'
--13、查询分数大于70,小于90的Sno列。
SELECT sno from (
SELECT sno,MIN(degree) as min_score,MAX(degree) as max_score
from score
GROUP BY sno) a
where a.min_score>70
and a.max_score <90;
--14、查询所有学生的Sname、Cno和Degree列。
select Sname,S.Cno,S.Degree
from Student,Score S
where Student.Sno=S.Sno
--15、查询所有学生的Sno、Cname和Degree列。
select Sno,Cname,Degree
from Course,Score
where Course.Cno=Score.Cno
--16、查询所有学生的Sname、Cname和Degree列。
select Sname,Cname,Degree
from Student,Score,Course
where Student.Sno=Score.Sno
and Score.Cno=Course.Cno
--17、 查询“95033”班学生的平均分。
select AVG(Degree)
from Student,Score
where Student.Sno=Score.Sno
and Class='95033'
--18、 假设使用如下命令建立了一个grade表:
--现查询所有同学的Sno、Cno和rank列。
--19、 查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录。
SELECT a.* from student a
INNER JOIN score b
on a.sno=b.sno
where b.degree>(select degree from score xinner join course y on x.cno=y.cnowhere sno='109' and cname='3-105');
--20、查询score中选学多门课程的同学中分数为非最高分成绩的记录。
select *
from Score A
where Degree<(select MAX(Degree)
from Score B
where A.Cno=B.Cno)
and Sno in(select Sno
from Score group by Sno having count(*)>1
)
--21、 查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。
select *
from student,Score
where student.Sno=Score.Sno
and Score.Degree>(select Degree
from Score
where Cno='3-105' and Sno='109')
--22、查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列。
select Sno,Sname,Sbirthday
from student
where year(student.Sbirthday)=(select year(Sbirthday)
from student
where Sno='107')
--23、查询“张旭“教师任课的学生成绩。
select Degree
from Score,Teacher,Course
where Teacher.Tname='张旭'
and Teacher.Tno=Course.Tno
and Course.Cno=Score.Cno
select Sno,Cno,Degree
from Score
where Cno in (select Cno
from Course
where Tno in ( select Tno
from Teacher
where Tname='张旭'
)
)
--24、查询选修某课程的同学人数多于5人的教师姓名。
select Tname
from Teacher
where Tno in (select Tno
from Course
where Cno in (select Cno
from Score
group by Cno having COUNT(*)>5
)
)
--25、查询95033班和95031班全体学生的记录。
select *
from student
where Class='95033' or Class='95031'
--26、查询存在有85分以上成绩的课程Cno.
select distinct Cno from Score where Degree>85
--27、查询出“计算机系“教师所教课程的成绩表。
select Sno,Cno ,Degree
from Score
where Cno in (select Cno
from Course
where Tno in (select Tno
from Teacher
where Depart='计算机系'
)
)
--29、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。
select Cno,Sno,Degree
from Score A
where (select Degree
from Score B
where Cno='3-105' and B.Sno=A.Sno)>=(select Degree
from Score C
where Cno='3-245' and C.Sno=A.Sno)
order by Degree DESC
select *
from Score
where Cno='3-105' and Degree >any(select Degree
from Score
where Cno='3-245')
--30、查询选修编号为“3-105”且成绩高于选修编号为“3-245”课程的同学的Cno、Sno和Degree.
select Cno,Sno,Degree
from Score A
where (select Degree
from Score B
where Cno='3-105' and B.Sno=A.Sno)>=(select Degree
from Score C
where Cno='3-245' and C.Sno=A.Sno
)
--31、 查询所有教师和同学的name、sex和birthday.
select distinct Sname as name,Ssex as sex,Sbirthday as birthday
from student
UNION
select distinct Tname as name,Tsex as sex,Tbirthday as birthday
from Teacher
--32、查询所有“女”教师和“女”同学的name、sex和birthday.
select distinct Sname as name,Ssex as sex,Sbirthday as birthday
from student
where Ssex='女'
UNION
select distinct Tname as name,Tsex as sex,Tbirthday as birthday
from Teacher
where Tsex='女'
--33、 查询成绩比该课程平均成绩低的同学的成绩表。
select Sno,Cno,Degree
from Score A
where A.Degree<(select AVG(Degree)
from Score B
where A.Cno=B.Cno)
--34、 查询所有任课教师的Tname和Depart.
select Tname,Depart
from Teacher
where Tname in (select distinct Tname
from Teacher,Course,Score
where Teacher.Tno=Course.Tno and Course.Cno=Score.Cno
)
select Tname,Depart
from Teacher
where tno in (select Tno from course
where Cno in (select distinct Cno
from Score
)
)
--35、 查询所有未讲课的教师的Tname和Depart.
select Tname,Depart
from Teacher
where Tname not in (select distinct Tname
from Teacher,Course,Score
where Teacher.Tno=Course.Tno and Course.Cno=Score.Cno
)
--36、查询至少有2名男生的班号。
select Class
from Student
where Ssex='男' group by Class having COUNT(*)>1
--37、查询Student表中不姓“王”的同学记录。
select *
from student
where Sname not like ('王%')
--38、查询Student表中每个学生的姓名和年龄。
select Sname,YEAR(GETDATE())-year(Sbirthday) from student
--39、查询Student表中最大和最小的Sbirthday日期值。
select MAX(Sbirthday) as 最大,MIN(Sbirthday) as 最小 from student
--40、以班号和年龄从大到小的顺序查询Student表中的全部记录。
select * from student order by Class desc,Sbirthday ASC
--42、查询最高分同学的Sno、Cno和Degree列。
select Tname,Cname
from Teacher,Course
where Tsex='男' and Teacher.Tno=Course.Tno
--43、查询和“李军”同性别的所有同学的Sname.
select Sname
from student
where Ssex=(select Ssex
from student
where Sname='李军') and Sname not in ('李军')
--44、查询和“李军”同性别并同班的同学Sname.
select Sname
from student
where Ssex=(select Ssex
from student
where Sname='李军')
and Sname not in ('李军')
and Class=(select Class
from student
where Sname='李军')
--45、查询所有选修“计算机导论”课程的“男”同学的成绩表。
select Sno,Degree
from Score
where Sno in (select Sno
from student
where Ssex='男')
and Cno in (select Cno
from Course
where Cname='计算机导论'
)
相关文章:

面试sql
创建表 create table Student ( Sno varchar(20) primary key,Sname varchar(20) UNIQUE,Ssex varchar(2),Sbirthday date,class varchar(20) )create table Course ( Cno varchar(20) primary key,Cname varchar(20) UNIQUE,Tno varchar(20) )create table Score ( …...

Python编程自动化办公案例(2)
作者简介:一名在校计算机学生、每天分享Python的学习经验、和学习笔记。 座右铭:低头赶路,敬事如仪 个人主页:网络豆的主页 目录 前言 一.前期代码 二.实现批量读取 1.os库 2.实现思路 (1&#…...

Vulnhub 渗透练习(七)—— FRISTILEAKS: 1.3
环境搭建 下载链接 virtualbox 打开靶机设置为 host-only,攻击机同样。 具体可点此处 信息收集 开了个 80 端口。 用的是 apache 2.2.15 ,这个版本有个解析漏洞。 目录 根据首页的图片猜测 /fristi/ 目录(不过我没想到 -_-&#x…...

阶段二10_面向对象高级_分类分包思想和案例环境搭建
一.分类思想 1.分类思想概念: 分工协作,专人干专事 2.信息管理系统分类[案例] Student 类-------------------->标准学生类,封装键盘录入的学生信息(id , name , age , birthday) StudentDao 类-----------------&…...

关于打印工具print-js的使用
https://www.jianshu.com/p/f6f09dd9f7db第一步 安装组件//安装print-js npm install print-js --save //删除print-js npm uninstall print-js //安装固定版本 npm install print-js版本号 --save // 全局安装 npm install print-js --save -g第二步 引入组件安装成功后&#…...

Doxygen使用
文章目录简介Doxygen的安装Doxygen的配置生成配置文件常用配置Doxygen注释头文件注释:函数的注释:Doxygen文档生成reference简介 Doxygen 是一个流行的用于生产代码文档的工具,关于它的介绍可以参考官网:https://www.doxygen.nl/index.html。 我使用Dox…...

MySQL数据库调优————表结构设计优化
三范式 第一范式 字段具有原子性,即数据库表的每一个字段都是不可分割的原子数据项,不能是集合、数组、记录等非原子数据项当实体中的每个属性有多个值时,必须拆分为不同的属性 第二范式 满足第一范式的基础上,要求每一行数据…...

set对象和map对象
1 Set对象 介绍: Set数据结构类似数组,但所有成员的值唯一。 Set本身为一个构造函数,用来生成 Set数据结构,使用 add方法来添加新成员。 let a new Set(); [1,2,2,1,3,4,5,4,5].forEach(x>a.add(x)); for(let k of a){ console.log(k…...

stream()流的使用
文章目录引入流流的操作中间操作终端操作流的使用谓词筛选筛选各异的元素流的切片截断流跳过元素映射流的扁平化查找和匹配归约元素求和、最大值和最小值数值流构建流由值构建流由数组创建流引入流 java api提供的一种利用声明式的方式处理数据集合的一个东西,可以…...

C++学习笔记-常量
在程序执行过程中,其值不能改变的量称为常量(Constant)。普通常量的类型是根据数据的书写形式来决定的。如 100 是整型常量,0.5 是实型常量,‘q’ 是字符型常量,“qianfeng” 是字符串常量。 常量是固定值,在程序执行期…...

JavaScript系列之实现继承的几种方式
文章の目录一、借助父构造函数继承属性1、实现方式2、优点3、缺点二、原型链继承1、实现方式2、优点3、缺点三、组合继承四、ES6继承的实现方式参考写在最后一、借助父构造函数继承属性 1、实现方式 先定义一个父构造函数(this指向为window);再定义一个子构造函数…...

java面试准备
1.自我介绍: 2.基础 : 1.集合 : java容器中分为collection 和map两大类 collection 分为list集合(有序且重复的),set集合(无序,不可重复) list集合分为arrayList集合 : 查询快,增删慢,它是基于数组结构的,对数据的增删是在数组的尾部进行添加或删除的,其效率相对于LinkedList…...

kafka-6-python单线程操作kafka
使用Python操作Kafka:KafkaProducer、KafkaConsumer Python kafka-python API的帮助文档 1 kafka tools连接 (1)/usr/local/kafka_2.13-3.4.0/config/server.properties listeners PLAINTEXT://myubuntu:9092 advertised.listenersPLAINTEXT://192.168.1.8:2909…...

【Spring教程】1.Spring概述
1、概述 1.1、Spring是什么? Spring 是一款主流的 Java EE 轻量级开源框架 ,Spring 由“Spring 之父”Rod Johnson 提出并创立,其目的是用于简化 Java 企业级应用的开发难度和开发周期。Spring的用途不仅限于服务器端的开发。从简单性、可测…...

设计模式-代理模式
控制和管理访问 玩过扮白脸,扮黑脸的游戏吗?你是一个白脸,提供很好且很友善的服务,但是你不希望每个人都叫你做事,所以找了黑脸控制对你的访问。这就是代理要做的:控制和管理对象。 监视器编码 需求&…...

DPDK — MALLOC(librte_malloc,Memory Manager,内存管理组件)
目录 文章目录 目录MALLOC(librte_malloc,Memory Manager,内存管理组件)rte_malloc() 接口malloc_heap 结构体malloc_elem 结构体内存初始化流程内存申请流程内存释放流程MALLOC(librte_malloc,Memory Manager,内存管理组件) MALLOC 库基于 hugetlbfs 内核文件系统来实…...

【Java开发】Spring 12 :Spring IOC控制反转和依赖注入(解决单接口多实现类调用)
IOC 是 Inversion of Control 的简写,译为“控制反转”,Spring 通过 IOC 容器来管理所有 Java 对象的实例化和初始化,控制对象与对象之间的依赖关系。我们将由 IOC 容器管理的 Java 对象称为 Spring Bean,它与使用关键字 new 创建…...

【C++学习】基础语法(三)
众所周知C语言是面向过程的编程语言,关注的是过程;解决问题前,需要分析求解的步骤,然后编辑函数逐步解决问题。C是基于面向对象的,关注的是对象,将一件事拆分成不同的对象,不同对象间交互解决问…...

k8s自动化安装脚本(kubeadm-1.23.7)
文章目录介绍软件架构版本介绍更新内容2023-02-192023-02-152023-02-142023-02-102022-10-202022-08-06准备部署包操作步骤环境准备结构备注解压部署包修改host文件脚本使用方式初始化环境验证ansible配置安装k8s集群登录master的节点添加node节点master节点状态检查组件安装安…...

面试题记录
Set与Map的区别 map是键值对,set是值的集合。键,值可以是任何类型map可以通过get获取,map不能。都能通过迭代器进行for…of遍历set的值是唯一的,可以做数组去重,map,没有格式限制,可以存储数据…...

链式前向星介绍以及原理
1 链式前向星 1.1 简介 链式前向星可用于存储图,本质上是一个静态链表。 一般来说,存储图常见的两种方式为: 邻接矩阵邻接表 邻接表的实现一般使用数组实现,而链式前向星就是使用链表实现的邻接表。 1.2 出处 出处可参考此…...

jenkins 安装 -适用于在线安装 后续写个离线安装的
jenkins安装1.下载jenkins2.安装启动3.附件卸载jdk的命令4.配置jenkins一、在jenkins配置文件中配置jdk环境变量二、修改jenkins默认的操作用户1.下载jenkins jenkins官网下载 https://www.jenkins.io/ 点击下载 我是centos系统所以选择centos,点击后按着官方提供…...

【C++】再谈vscode界面调试C++程序(linux) - 知识点目录
再谈vscode界面调试C程序(linux) 配套文档:vscode界面调试C程序(linux) 命令解释 g -g ../main.cpp 编译main.cpp文件; -g:生成调试信息。编译器会在可执行文件中嵌入符号表和源代码文件名&…...

蚂蚁感冒---第五届蓝桥杯真题
目录 题目链接 题目描述 分析: 代码: y总综合 666 题目链接 1211. 蚂蚁感冒 - AcWing题库 题目描述 分析: y总真牛逼,掉头等价于穿过,以第一个点为分界点,分别判断 代码: (自…...

常见排序算法--Java实现
常见排序算法--Java实现插入排序直接插入排序折半插入排序希尔排序交换排序冒泡排序快速排序选择排序直接选择排序堆排序归并排序基数排序各种排序方法比较在网上找了些排序算法的资料。此篇笔记本人总结比较,简单注释,觉得比较好理解,且相对…...

算法笔记(九)—— 暴力递归
暴力递归(尝试) 1. 将问题转化为规模缩小了的同类问题子问题 2. 有明确的不需要的继续递归的条件 3. 有当得到子问题结果之后的决策过程 4. 不记录每一个子问题的解 Question:经典汉诺塔问题 1. 理解清楚,基础三个圆盘的移动…...

Flask框架学习记录
Flask项目简要 项目大致结构 flaskDemo1 ├─static ├─templates └─app.py app.py # 从flask这个包中导入Flask类 from flask import Flask# 使用Flask类创建一个app对象 # __name__:代表当前app.py这个模块 # 1.以后出现bug,可以帮助快速定位 # 2.对于寻找…...

【Opencv 系列】 第6章 人脸检测(Haar/dlib) 关键点检测
本章内容 1.人脸检测,分别用Haar 和 dlib 目标:确定图片中人脸的位置,并画出矩形框 Haar Cascade 哈尔级联 核心原理 (1)使用Haar-like特征做检测 (2)Integral Image : 积分图加速特征计算 …...

信源分类及数学模型
本专栏包含信息论与编码的核心知识,按知识点组织,可作为教学或学习的参考。markdown版本已归档至【Github仓库:information-theory】,需要的朋友们自取。或者公众号【AIShareLab】回复 信息论 也可获取。 文章目录信源分类按照信源…...

Games101-202作业1
一. 将模型从模型空间变换到世界空间下 在这个作业下,我们主要进行旋转的变换。 二.视图变换 ,将相机移动到坐标原点,同时保证物体和相机进行同样的变换(这样对形成的图像没有影响) 在这个作业下我们主要进行摄像机的平移变换&am…...