diff --git "a/02\346\210\230\345\275\271\345\206\233/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" "b/02\346\210\230\345\275\271\345\206\233/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/git.PNG" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/git.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..d5c7e6b226da696eb3121d01389560a22b94a52a Binary files /dev/null and "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/git.PNG" differ diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/sql.png" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/sql.png" new file mode 100644 index 0000000000000000000000000000000000000000..b3668531802d22edc360e3a3d04e2164da38c355 Binary files /dev/null and "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\200\346\254\241\344\275\234\344\270\232/sql.png" differ diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.sql" new file mode 100644 index 0000000000000000000000000000000000000000..422d5b76604467f2c6019e24e56214293a543ac7 --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.sql" @@ -0,0 +1,200 @@ +create database Student; +go +-- 使用这个库 +use Student; +go + + +-------------------- +-- 建表部分 +-------------------- +-- 创建班级表,存储班级信息,其中字段包含:班级id、班级名称 +create table Class( + ClassId int not null identity(1,1), + ClassName nvarchar(50) not null +); +go + +-- 创建学生表,存储学生信息,其中字段保护:学生id、姓名、性别、生日、家庭住址,所属班级id +create table Student ( + StudentId int not null identity(1, 1), + StudentName nvarchar(50), + StudentSex tinyint not null, + StudentBirth date, + StudentAddress nvarchar(255) not null, + classid int, +); +go + +-- 创建课程表,存储课程信息,其中字段包含:课程id、课程名称、课程学分 +create table Course( + CourseId int identity(1,1), + CourseName nvarchar(50), + CourseCredit int +); +go + +-- 创建班级课程表,存储班级课程信息,其中字段包含:自增id、班级id、课程id +create table ClassCourse( + ClassCourseId int identity(1,1), + ClassId int, + CourseId int +); +go + +-- 创建分数表,存储学生每个课程分数信息,其中字段包含:分数id、学生id、课程id、分数 +create table Score( + ScoreId int identity(1,1), + StudentId int, + CourseId int, + Score int +); +go + + +-- 学生表建好了,细想一下少了一个所属班级的字段 +-- 给学生表 Student 增加一个所属班级id字段 +alter table Student add ClassId int not null; +go + +---------------------------------------- +-- 创建约束部分,使用alter进行修改 +---------------------------------------- +-- 班级表 ClassId 字段需要设置为主键(主键约束) +alter table Class add constraint PK_Class_ClassId primary key (ClassId); +-- 学生表 StudentId 字段需要设置为主键(主键约束) +alter table Student add constraint PK_Student_StudentId primary key (StudentId); +-- 课程表 CourseId 字段需要设置为主键(主键约束) +alter table Course add constraint PK_Course_CourseId primary key (CourseId); +-- 班级课程表 ClassCourseId 字段需要设置为主键(主键约束) +alter table ClassCourse add constraint PK_ClassCourse_ClassCourseId primary key (ClassCourseId); +-- 分数表 ScoreId 字段需要设置为主键(主键约束) +alter table Score add constraint PK_Score_ScoreId primary key (ScoreId); + +-- 学生表 StudentName 不允许为空(非空约束) +alter table Student alter column StudentName nvarchar(50) not null; + +-- 班级表 ClassName 需要唯一(唯一约束) +alter table Class add constraint UQ_Class_ClassName unique(ClassName); +-- 课程表 CourseName 需要唯一(唯一约束) +alter table Course add constraint UQ_Course_CourseName unique(CourseName); + +-- 学生表 ClassId 增加默认值为0(默认值约束) +alter table Student add constraint DF_Student_ClassId default(0) for ClassId; + +-- 学生表 StudentSex 只能为1或者2(Check约束) +alter table Student add constraint CK_Student_StudentSex check(StudentSex=1 or StudentSex=2); +-- 分数表 Score 字段只能大于等于0(check约束) +alter table Score add constraint CK_Score_Score check(Score>=0); +-- 课程表 CourseCredit 字段只能大于0(check约束) +alter table Course add constraint CK_Course_CourseCredit check(CourseCredit>=0); + +-- 班级课程表ClassId 对应是 班级表ClassId 的外键 (外键约束) +alter table ClassCourse add constraint FK_ClassCourse_ClassId foreign key (ClassId) references Class(ClassId); +-- 班级课程表CourseId 对应是 课程表CourseId 的外键 (外键约束) +alter table ClassCourse add constraint FK_ClassCourse_CourseId foreign key (CourseId) references Course(CourseId); +-- 分数表StudentId 对应是 学生表StudentId 的外键 (外键约束) +alter table Score add constraint FK_Score_StudentId foreign key (StudentId) references Student(StudentId); +-- 分数表CourseId 对应是 课程表CourseId 的外键 (外键约束) +alter table Score add constraint FK_Score_CourseId foreign key (CourseId) references Course(CourseId); + + +-------------------- +-- 插入数据部分 +-------------------- +-- 学校开设了3个班级:软件一班、软件二班、计算机应用技术班。请插入班级表相关数据 +insert into Class (ClassName) values ('软件一班'); +insert into Class (ClassName) values ('软件二班'); +insert into Class (ClassName) values ('计算机应用技术班'); + +-- 软件一班有3个同学,姓名、性别、生日、家庭住址 分别是: +-- 刘正、男、2000-01-01、广西省桂林市七星区空明西路10号鸾东小区 +-- 黄贵、男、2001-03-20、江西省南昌市青山湖区艾溪湖南路南150米广阳小区 +-- 陈美、女、2000-07-08、福建省龙岩市新罗区曹溪街道万达小区 +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress, ClassId) + values ('刘正',1,'2000-01-01','广西省桂林市七星区空明西路10号鸾东小区', 1); +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress, ClassId) + values ('黄贵',1,'2001-03-20','江西省南昌市青山湖区艾溪湖南路南150米广阳小区', 1); +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress, ClassId) + values ('陈美',2,'2000-07-08','福建省龙岩市新罗区曹溪街道万达小区', 1); + +-- 软件二班有2个同学,姓名、性别、生日、家庭住址 分别是: +-- 江文、男、2000-08-10、安徽省合肥市庐阳区四里河路与潜山路交汇处万科城市之光 +-- 钟琪、女、2001-03-21、湖南省长沙市雨花区红花坡社区 +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress, ClassId) + values ('江文',1,'2000-08-10','安徽省合肥市庐阳区四里河路与潜山路交汇处万科城市之光', 2); +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress, ClassId) + values ('钟琪',2,'2001-03-21','湖南省长沙市雨花区红花坡社区', 2); + +-- 计算机应用技术班有4个同学,姓名、性别、生日、家庭住址 分别是: +-- 曾小林、男、1999-12-10、安徽省合肥市庐阳区四里河路与潜山路交汇处万科城市之光 +-- 欧阳天天、女、2000-04-05、湖北省武汉市洪山区友谊大道与二环线交汇处融侨悦府 +-- 徐长卿、男、2001-01-30、江苏省苏州市苏州工业园区独墅湖社区 +-- 李逍遥、男、1999-11-11、广东省广州市白云区金沙洲岛御洲三街恒大绿洲 +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress, ClassId) + values ('曾小林',1,'1999-12-10','安徽省合肥市庐阳区四里河路与潜山路交汇处万科城市之光', 3); +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress, ClassId) + values ('欧阳天天',2,'2000-04-05','湖北省武汉市洪山区友谊大道与二环线交汇处融侨悦府', 3); +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress, ClassId) + values ('徐长卿',1,'2001-01-30','江苏省苏州市苏州工业园区独墅湖社区', 3); +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress, ClassId) + values ('李逍遥',1,'1999-11-11','广东省广州市白云区金沙洲岛御洲三街恒大绿洲', 3); +insert into Student(StudentName, StudentSex, StudentBirth, StudentAddress) + values('东方不败',3,'1999-12-11','河北省平定州西北四十余里的猩猩滩'), + ('令狐冲',1,'2000-08-11','陕西省渭南市华阴市玉泉路南段'); + +-- 软件一班开设课程,课程名称和学分分别为: +-- 数据库高级应用、3 +-- javascript编程基础、3 +-- web前端程序设计基础、4 +-- 动态网页设计.net基础、6 +insert into Course(Courseid,CourseName, CourseCredit) + values (1,'数据库高级应用', 3), + (1,'javascript编程基础', 3), + (1,'web前端程序设计基础', 4), + (1,'动态网页设计.net基础', 6), + (2,'数据库高级应用', 3), + (2,'javascript编程基础', 3), + (2,'web前端程序设计基础', 4), + (2,'动态网页设计.net基础', 6), + (3,'数据库高级应用', 3), + (3,'javascript编程基础', 3), + (3,'web前端程序设计基础', 4), + (3,'动态网页设计php基础',5); + +insert into Score (StudentId, CourseId, Score) + values (1,1,80),(1,2,80),(1,3,78),(1,4,90), + (2,1,60),(2,2,77),(2,3,68),(2,4,88), + (3,1,88),(3,2,45),(3,3,66),(3,4,75), + (4,1,56),(4,2,80),(4,3,75),(4,4,66), + (5,1,88),(5,2,79),(5,3,72),(5,4,85), + (6,1,68),(6,2,88),(6,3,73),(6,4,63), + (7,1,84),(7,2,90),(7,3,92),(7,4,78), + (8,1,58),(8,2,59),(8,3,65),(8,5,75), + (9,1,67),(9,2,71),(9,3,56),(9,5,48); + +select*from Class; +select*from Student; +select*from Course; +select*from ClassCourse; +select*from Score; +select StudentName,StudentAddress from Student; +select top 20 percent *from Student; +select distinct Classid from Student; +select Studentid from Score where Score is not null; +select*from Course order by CourseCredit desc; +select*from Score order by score asc; +select*from Student order by StudentBirth asc; +select*from Student where ClassId=1; +select*from Student where StudentSex='女'; +select*from Student where StudentBirth>='2000-01-01'and StudentBirth<='2000-12-31'; +select*from Student where StudentName like'%欧阳%'; +select*from Student where StudentAddress like'%桂林市%'; +select*from Student where StudentName like'李__'; +select count(0) from Student where ClassId=1; +select count(0) from ClassCourse where ClassId=1; +select sum(Score) from Score where StudentId=1; +select avg(Score) from Score where CourseId=1; +select StudentId, sum(Score) as TotalScore from Score group by StudentId; +select StudentId, avg(Score) as TotalScore from Score group by StudentId; +select StudentId, avg(Score) as AvgScore from Score group by StudentId order by AvgScore desc; diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.PNG" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..4028768dd67dd98c08b44e204fc69b3c5c7c28bc Binary files /dev/null and "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.PNG" differ diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.sql" new file mode 100644 index 0000000000000000000000000000000000000000..d53544d92cae1c338598e1e8b44cad95e6f9e02e --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232/\347\254\254\344\270\211\346\254\241\344\275\234\344\270\232.sql" @@ -0,0 +1,41 @@ +create database Class; +use Class; +create table Classinfor( +ClassId int primary key identity(1,1) not null, --班级编号 +ClassName nvarchar(50) not null unique, --班级名称 +); + +create table Studentinfor( +StudentId int primary key identity(1,1) not null, --学生编号 +StudentName nvarchar(50) not null, --学生姓名 +StudentSex tinyint not null default'3' check(StudentSex='1'or StudentSex='2'or StudentSex='3'), --学生性别 +StudentBirth date, --学生生日 +StudentAddress nvarchar(255) not null, --学生地址 +ClassId int not null, --所属班级id +StudentIdentityCard varchar(20) not null default'' --身份证 +); + +create table Courseinfor( +Course int primary key identity(1,1) not null, --课程编号 +CourseName nvarchar(50) not null unique, --课程名称 +CourseCredit tinyint not null default'0' check(CourseCredit>'0'), --课程学分 +); + +create table ClassCourse( +ClassCourseId int primary key identity(1,1) not null, --自增编号 +ClassId int not null default'0', --班级编号 +Course int not null, --课程编号 +foreign key(ClassId) references Classinfor(ClassId), +foreign key(Course) references Courseinfor (Course), +); + +create table Scoreid( +ScoreId int primary key identity(1,1) not null, --自增编号 +StudentId int not null, --学生编号 +CourseId int not null, --课程编号 +Score int not null check(Score>='0'), --分数 +sResit tinyint not null default'0' --是否是补考:0不是,1是 +foreign key(StudentId) references Studentinfor(StudentId), +foreign key(Courseid) references Courseinfor(Course) +); + diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\230\266\346\256\265\344\272\214\357\274\2101\357\274\211.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\230\266\346\256\265\344\272\214\357\274\2101\357\274\211.sql" new file mode 100644 index 0000000000000000000000000000000000000000..ae1c05b81fb08a749a57ef42e3f6965742231c3f --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\230\266\346\256\265\344\272\214\357\274\2101\357\274\211.sql" @@ -0,0 +1,80 @@ +create database jd2; +go +use jd2; +--学生信息表 +create table stuInfo ( +stuID int primary key, +stuName nvarchar(33), +stuAge int, +stuSex int, +time datetime +); +--课程信息表 +create table courseInfo( +courseID int identity(1,1), +courseName nvarchar(33), +courseMarks int +); +--分数信息表 +create table scoreInfo( +scoreID int identity(1,1), +stuID int, +courseID int, +score int +); +insert into stuInfo(stuID,stuName,stuAge,stuSex,time) + values(1,'Tom',19,1,''), + (2,'Jack',20,0,''), + (3,'Rose',21,1,''), + (4,'Lulu',19,1,''), + (5,'Lili',21,0,''), + (6,'abc',20,1,'2007-01-07 01:11:36.590'); +insert into courseInfo(courseName,courseMarks) + values('JavaBase',4), + ('HTML',2), + ('JavaScript',2), + ('SqlBase',2); +insert into scoreInfo(stuID,courseID,score) + values(1,1,80), + (1,2,85), + (1,4,50), + (2,1,75), + (2,3,45), + (2,4,75), + (3,1,45), + (4,1,95), + (4,2,75), + (4,3,90), + (4,4,45); +--1.查询出每个学生所选修的课程的数量和所选修的课程的考试的平均分 +select stuName 姓名, count(courseID) 课程数量,avg(score) 平均分 from stuInfo inner join scoreInfo on stuInfo.stuID=scoreInfo.stuID group by stuName; +--2.查询出每门课程的选修的学生的个数和学生考试的总分 +select courseName 课程名称,count(scoreInfo.courseID) 学生个数,sum(score) 考试总分 from courseInfo inner join scoreInfo on courseInfo.courseID=scoreInfo.courseID group by courseName; +--3.查询出性别一样并且年龄一样的学生的信息 +select*from stuInfo son inner join stuInfo father on son.stuSex=father.stuSex and son.stuAge=father.stuAge where son.stuID!=father.stuID; +--4.查询出学分一样的课程信息 +select*from courseInfo son inner join courseInfo father on son.courseMarks=father.courseMarks where son.courseID!=father.courseID; +--5.查询出参加了考试的学生的学号,姓名,课程号和分数 +select stuInfo.stuID 学号 , stuName 姓名 , courseInfo.courseID 课程号 , score 分数 from stuInfo + inner join scoreInfo on stuInfo.stuID=scoreInfo.stuID + inner join courseInfo on scoreInfo.courseid=courseInfo.courseid + where score!=0; +--6.查询出参加了考试的学生的学号,课程号,课程名,课程学分和分数 +select stuInfo.stuID 学号 , stuName 姓名 , courseInfo.courseID 课程号 , courseName 课程名 , courseMarks 课程学分 , score 分数 from stuInfo +inner join scoreInfo on stuInfo.stuID=scoreInfo.stuID +inner join courseInfo on scoreInfo.courseID=courseInfo.courseID +where score!=0 +--7.查询出没有参加考试的学生的学号和姓名 +select stuInfo.stuID 学号 , stuName 姓名 from stuInfo +inner join scoreInfo on stuInfo.stuID=scoreInfo.stuID +inner join courseInfo on scoreInfo.courseID=courseInfo.courseID +where score=0; +--8.查询出是周六周天来报到的学生 +select * from stuInfo where time!='' +--9.查询出姓名中有字母a的学生的信息 +select * from stuInfo where stuName like 'a%' +--10.查询出选修了2门课程以上的并且考试平均分在70以上的学生的学号和考试平均分以及选修课程的数量 +select stuInfo.stuID 学号 , sum(score) 平均分 ,count(courseID) 选修课程数量 from stuInfo +inner join scoreInfo on stuInfo.stuAge=scoreInfo.stuID +group by stuInfo.stuID +having count(courseID)>2 and avg(score)>70 \ No newline at end of file diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\230\266\346\256\265\344\272\214\357\274\2102\357\274\211.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\230\266\346\256\265\344\272\214\357\274\2102\357\274\211.sql" new file mode 100644 index 0000000000000000000000000000000000000000..cdf3b82abfce4b723fc21e00fdcbdeaf9561b2cf --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\271\235\346\254\241\344\275\234\344\270\232/\351\230\266\346\256\265\344\272\214\357\274\2102\357\274\211.sql" @@ -0,0 +1,86 @@ +create database jd2; +use jd2 +create table tbl_card( +id nvarchar(10) primary key, --卡号,主键 +passWord nvarchar(10), --密码 +balance money, --卡上的余额 +userName nvarchar(5), --该上网卡所属的用户名 +); +create table tbl_computer( +id nvarchar(10) primary key, --机器编号,主键 +onUse tinyint, --该机器是否正在使用,0为未使用,1为正在使用 +note int --该机器的说明 +); +create table tbl_record( +id nvarchar(10) primary key, --记录编号,主键 +cardId nvarchar(10), --本次上网的卡号,外键 +ComputerId nvarchar(5) references tbl_computer(id) , --本次上网记录所使用的机器号,外键 +beginTime datetime, --本次上网记录的开始时间 +endTime datetime, --本次上网记录的结束时间 +fee money --本次上网的费用 +); + +insert into tbl_card(id,passWord,balance,userName) + values('0023_ABC','555',98,'张军'), + ('0025_bbd','abe',300,'朱俊'), + ('0036_CCD','何柳',100,'何柳'), + ('0045_YGR','0045_YGR',58,'证验'), + ('0078_RJV','55885fg',600,'校庆'), + ('0089_EDE','zhang',134,'张峻'); + +insert into tbl_computer(id,onUse,note) + values('02',0,25555), + ('03',1,55555), + ('04',0,66666), + ('05',1,88888), + ('06',0,688878), + ('B01',0,558558); + +insert into tbl_record(id,cardId,ComputerId,beginTime,endTime,fee) + values(23,'0078_RJV','B01','2007-07-15 19:00:00','2007-07-15 21:00:00',20), + (34,'0025_bbd','02','2006-12-25 18:00:00','2006-12-25 22:00:00',23), + (45,'0023_ABC','03','2006-12-23 15:26:00','2006-12-23 22:55:00',50), + (46,'0023_ABC','03','2006-12-22 15:26:00','2006-12-22 22:55:00',6), + (47,'0023_ABC','03','2006-12-23 15:26:00','2006-12-22 22:55:00',50), + (48,'0023_ABC','03','2007-01-06 15:26:00','2007-01-06 22:55:00',6), + (55,'0023_ABC','03','2006-07-21 15:26:00','2006-07-21 22:55:00',50), + (64,'0045_YGR','04','2006-12-24 18:00:00','2006-12-24 22:00:00',300), + (65,'0025_bbd','02','2006-12-28 18:00:00','2006-12-28 22:00:00',23), + (98,'0025_bbd','02','2006-12-26 18:00:00','2006-12-16 22:00:00',23); + +--1. 查询出用户名为'张军'的上网卡的上网记录,要求显示卡号,用户名,机器编号、开始时间、结束时间,和消费金额,并按消费金额降序排列 +select tbl_card.id 卡号,username 用户名,ComputerId 机器编号,beginTime 开始时间,endtime 结束时间,fee 消费金额 +from tbl_card inner join tbl_record on tbl_card.id=tbl_record.id +where userName='张军' +order by fee; +--2. 查询出每台机器上的上网次数和消费的总金额 +select ComputerId,count(*) 上网次数,sum(fee) 总金额 from tbl_record +group by ComputerId; +--3. 查询出所有已经使用过的上网卡的消费总金额 +select carid,sum(fee) 总金额 from tbl_record +group by carid; +--4. 查询出从未消费过的上网卡的卡号和用户名 +select * from tbl_card +left join tbl_record on tbl_card.id = tbl_record.carid +where fee is null; +--5. 将密码与用户名一样的上网卡信息查询出来 +select * from tbl_card where username=passWord; +--6. 查询出使用次数最多的机器号和使用次数 + +--7. 查询出卡号是以'ABC'结尾的卡号,用户名,上网的机器号和消费金额 +select 用户名=username,ComputerId 机器号,fee 消费金额 from tbl_card inner join tbl_record on tbl_card.id = tbl_record.carid +where carid like '%ABC'; +--8. 查询出是周六、周天上网的记录,要求显示上网的卡号,用户名,机器号,开始时间、结束时间和消费金额 +select 卡号 =id,用户名=username,ComputerId 机器号,fee 消费金额 from tbl_card inner join tbl_record on tbl_card.id = tbl_record.carid +where datepart(weekday,beginTime)=1 or datepart(weekday,beginTime)=7; +--9. 查询成一次上网时间超过12小时的的上网记录,要求显示上网的卡号,用户名,机器号,开始时间、结束时间和消费金额 + +--10. 查询除消费金额排列前三名(最高)的上网记录,要求显示上网的卡号,用户名,机器号,开始时间、结束时间和消费金额 +select * from tbl_card inner join +tbl_record on tbl_card.id= tbl_record.carid +where fee not in ( +select top 3 fee from tbl_record order by fee desc) +; + + + diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.PNG" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..1375e49a7cd20ab353a06915d410a462f057cb6a Binary files /dev/null and "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.PNG" differ diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.sql" new file mode 100644 index 0000000000000000000000000000000000000000..8f653e47aa1cfc3a9d752e823d17d0b6bca6a935 --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\214\346\254\241\344\275\234\344\270\232.sql" @@ -0,0 +1,34 @@ +create database Class; +create table Classinfor( +classid int, --班级编号 +classname nvarchar(50),--班级名称 +); + +create table Studentinfor( +StudentId int, --班级编号 +StudentName nvarchar(50), --学生姓名 +StudentSex tinyint, --学生性别 +StudentBirth date, --学生生日 +StudentAddress nvarchar(255), --学生地址 +ClassId int, --所属班级id +); + +create table Courseinfor( +Course int, --课程编号 +CourseName nvarchar(50), --课程名称 +CourseCredit tinyint, --课程学分 +); + +create table ClassCourse( +ClassCourseId int, --自增编号 +ClassId int, --班级编号 +CourseId int, --课程编号 +); + +create table Scoreid( +ScoreId int, --自增编号 +StudentId int, --学生编号 +CourseId int, --课程编号 +Score int, --分数 +); + diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232.PNG" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..2c5e9ccd92c61e2711231e39a37eff49f78b2093 Binary files /dev/null and "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232.PNG" differ diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232.sql" new file mode 100644 index 0000000000000000000000000000000000000000..70429b31e427e2e3f7026ed9258a30e1493440bf --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232/\347\254\254\344\272\224\346\254\241\344\275\234\344\270\232.sql" @@ -0,0 +1,35 @@ +create database Student; +go +use Student; +create table Class( + ClassId int not null identity(1,1), + ClassName nvarchar(50) not null +); +create table Student ( + StudentId int not null identity(1, 1), + StudentName nvarchar(50), + StudentSex tinyint not null, + StudentBirth date, + StudentAddress nvarchar(255) not null, + ClassId int +); +insert into Class (ClassName) + values ('软件一班') + ,('软件二班') + ,('计算机应用技术班'); +insert into Student (StudentName, StudentSex, StudentBirth, StudentAddress,ClassId) + values('刘正',1,'2000-01-01','广西省桂林市七星区空明西路10号鸾东小区',1) + ,('黄贵',1,'2001-03-20','江西省南昌市青山湖区艾溪湖南路南150米广阳小区',1) + ,('陈美',2,'2000-07-08','福建省龙岩市新罗区曹溪街道万达小区',1) + ,('江文',1,'2000-08-10','安徽省合肥市庐阳区四里河路与潜山路交汇处万科城市之光',2) + ,('钟琪',2,'2001-03-21','湖南省长沙市雨花区红花坡社区',2) + ,('曾小林',1,'1999-12-10','安徽省合肥市庐阳区四里河路与潜山路交汇处万科城市之光',3) + ,('欧阳天天',2,'2000-04-05','湖北省武汉市洪山区友谊大道与二环线交汇处融侨悦府',3) + ,('徐长卿',1,'2001-01-30','江苏省苏州市苏州工业园区独墅湖社区',3) + ,('李逍遥',1,'1999-11-11','广东省广州市白云区金沙洲岛御洲三街恒大绿洲',3); + +insert into Student(StudentName, StudentSex, StudentBirth, StudentAddress) + values ('东方不败',3,'1999-12-11','河北省平定州西北四十余里的猩猩滩') + ,('令狐冲',1,'2000-08-11','陕西省渭南市华阴市玉泉路南段') + + \ No newline at end of file diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/lx1.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/lx1.sql" new file mode 100644 index 0000000000000000000000000000000000000000..8ae3cd84773341fb76fe8e6515292e0e59be40a9 --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/lx1.sql" @@ -0,0 +1,38 @@ +create database zy1; +go +use zy1; +create table student( +stuNO nvarchar(37), +stuName nvarchar(33), +stuAge tinyint, +stuAddress nvarchar(77), +stuSeat int identity(1, 1), +stuSex char(1) check(stusex=1 or stusex=0), +); +create table exam( +examNO int identity, +stuNO nvarchar(33), +writtenExam int, +labExam int +); +insert into student(stuNO,stuName,stuAge,stuAddress,stuSex) + values('s2501','张秋利',20,'美国硅谷',1), + ('s2502','李思文',18,'湖北武汉',0), + ('s2503','马文才',22,'湖南长沙',1), + ('s2504','欧阳俊雄',21,'湖北武汉',0), + ('s2505','梅超风',20,'湖北武汉',1), + ('s2506','陈旋风',19,'美国硅谷',1), + ('s2507','陈风',20,'美国硅谷',0); +insert into exam(stuNO,writtenExam,labExam) + values('s2501',50,70), + ('s2502',60,65), + ('s2503',86,85), + ('s2504',40,80), + ('s2505',70,90), + ('s2506',85,90); +select stuName 姓名,stuAge 年龄,writtenExam 笔试,labExam 机试 from student inner join exam on student.stuNO=exam.stuNO; +select student.stuNO 学号, stuName 姓名,writtenExam 笔试,labExam 机试 from student inner join exam on student.stuNO=exam.stuNO where writtenExam>60 and labExam>60; +select student.stuNO 学号, stuName 姓名,writtenExam 笔试,labExam 机试 from student full join exam on student.stuNO=exam.stuNO; +select stuName 姓名,stuAge 年龄,writtenExam 笔试,labExam 机试 from student full join exam on student.stuNO=exam.stuNO where stuAge>=20 order by writtenExam desc; +select avg(labExam) 机试,stuSex 性别 from student inner join exam on student.stuNO=exam.stuNO group by stuSex; +select sum(writtenExam) 机试,stuSex 性别 from student inner join exam on student.stuNO=exam.stuNO group by stuSex; \ No newline at end of file diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/lx2.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/lx2.sql" new file mode 100644 index 0000000000000000000000000000000000000000..27ebd93244de2050a5076f1d58d513eec549f2ed --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/lx2.sql" @@ -0,0 +1,51 @@ +create database zy2; +go + +use zy2; +create table orders( +orderID int primary key, +orderDate datetime +); + +create table item( +itemId int identity(1,1), +orderid int, +itemType nvarchar(33), +itemName nvarchar(33), +theNumber int, +theMoney money +); + +insert into orders(orderID,orderDate) + values(1,'2008-01-12 00:00:00.000' ), + (2,'2008-02-10 00:00:00.000'), + (3,'2008-02-15 00:00:00.000'), + (4,'2008-03-10 00:00:00.000'); + +insert into item(orderid,itemType,itemName,theNumber,theMoney) + values(1,'文具','笔',72,2), + (1,'文具','尺',10,1), + (1,'体育用品','篮球',1,56), + (2,'文具','笔',36,2), + (2,'文具','固体胶',20,3), + (2,'日常用品','透明胶',2,1), + (2,'体育用品','羽毛球',20,3), + (3,'文具','订书机',20,3), + (3,'文具','订书针',10,3), + (3,'文具','裁纸刀',5,5), + (4,'文具','笔',20,2), + (4,'文具','信纸',50,1), + (4,'日常用品','毛巾',4,5), + (4,'日常用品','透明胶',30,1), + (4,'体育用品','羽毛球',20,3); +select orders.orderID 订单编号,orderDate 订单日期, itemType 产品类别, itemName 产品名称,theNumber 订购数量,theMoney 订购单价 from orders inner join item on item.orderid=orders.orderID; + +select orders.orderID 订单编号,orderDate 订单日期, itemType 产品类别, itemName 产品名称 from orders inner join item on item.orderid=orders.orderID where theNumber>50; + +select orders.orderID 订单编号,orderDate 订单日期, itemType 产品类别, itemName 产品名称,theNumber 订购数量,theMoney 订购单价,theNumber*theMoney 总价 from orders inner join item on item.orderid=orders.orderID; + +select orders.orderID 订单编号,orderDate 订单日期, itemType 产品类别, itemName 产品名称,theNumber 订购数量,theMoney 订购单价,theNumber*theMoney 总价 from orders inner join item on item.orderid=orders.orderID where theMoney>=5 and theNumber>=50; + +select orderid,count(itemName) 订购产品数 from item group by orderid; + +select orderid 订单编号,itemType 产品类别,count(theNumber) 订购次数,sum(theNumber) 总数量 from item group by orderid,itemType; \ No newline at end of file diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/zy4.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/zy4.sql" new file mode 100644 index 0000000000000000000000000000000000000000..5dab9673fda6fffea440d20abeec38742a2788fa --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/zy4.sql" @@ -0,0 +1,16 @@ + + +--1. 查询 李逍遥(编号id为9) 所在的班级名称(连接查询 2表) +select studentname,classname from class join student on class.classid=student.classid where studentid=9; +--2. 查询 李逍遥(学生编号id为9) 学习的课程有哪几门,需要姓名、课程名称、课程学分(连接查询) +select studentname,coursename,coursecredit from course join student on course.classid=student.classid; +--3. 查询 李逍遥(学生编号id为9) 学习的课程考试得分,需要姓名、课程名称、课程学分、得分(连接查询) +select studentname ,coursename,coursecredit,score from course join student on course.classid=student.classid +join score on course.courseid=score.courseid; +--4. 使用子查询查询 软件一班的每个学生 的平均分(聚合查询 + 子查询 + 分组) +select studentname 姓名,avg(score) 平均分 from score join student on score.studentid=student.studentid where classid in(select classid from class where classname='软件一班') group by studentname +--5. 使用连接查询 软件二班的每个学生 的平均分(聚合查询 + 连接查询 + 分组) +select studentname,avg(score) 平均分 from score join student on score.studentid=student.studentid where classid=2 group by studentname; +--6. 按照班级查询所有课程的平均分,并且按照平均分高低进行排序。(聚合查询 + 连接查询 + 分组) +select classname,coursename,avg(score)平均分 from score join course on score.courseid=course.coursecredit +join class on class.classid=course.classid group by classname,coursename order by avg(score); \ No newline at end of file diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/zy1.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/zy1.sql" new file mode 100644 index 0000000000000000000000000000000000000000..d91092c8b45502ac12624311b83139f04604fb06 --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/zy1.sql" @@ -0,0 +1,65 @@ +create database zy1; +go +use zy1; +create table student( +stuNO nvarchar(37) primary key, +stuName nvarchar(33), +stuAge int, +stuAddress nvarchar(77), +stuSeat int identity(1, 1), +stuSex char(1) check(stusex=1 or stusex=0), +); +create table exam( +examNO int identity(1,1), +stuNO int, +writtenExam int, +labExam int +); +insert into student(stuNO,stuName,stuAge,stuAddress,stuSex) + values('s2501','张秋利',20,'美国硅谷',1), + ('s2502','李思文',18,'湖北武汉',0), + ('s2503','马文才',22,'湖南长沙',1), + ('s2504','欧阳俊雄',21,'湖北武汉',0), + ('s2505','梅超风',20,'湖北武汉',1), + ('s2506','陈旋风',19,'美国硅谷',1), + ('s2507','陈风',20,'美国硅谷',0); +insert into exam(writtenExam,labExam) + values(50,70), + (60,65), + (86,85), + (40,80), + (70,90), + (85,90); +select stuNO 学号,stuName 姓名,stuAge 年龄,stuAddress 地址,stuSex 性别 from student; +select stuName,stuAge,stuAddress from student; +select stuNO 学号,writtenExam as 笔试,机试=labExam from exam; +select stuNO,stuName,stuAddress,cast(stuName+'@'+stuAddress as varchar(66)) 邮箱 from student; +select stuNO,writtenExam,labExam,cast(writtenExam+labExam as int)总分 from exam; +select distinct stuAddress from student; +select distinct stuAge 年龄 from student; +select top 3* from student; +select top 4 stuName,stuNO from student; +select top 50 percent*from student; +select*from student where stuAddress='湖北武汉'and stuAge=20; +select*from exam where labExam>=60 and labExam<=80 order by labExam desc; +select*from exam where labExam between 60 and 80 order by labExam desc; +select*from student where stuAddress in('湖北武汉','湖南长沙'); +select *from student where stuAddress='湖北武汉'or stuAddress='湖南长沙'; +select*from exam where writtenExam<=70 or writtenExam>=90 order by writtenExam asc; +select*from exam where writtenExam not between 70 and 90; +select*from student where stuAge is null; +select*from student where stuAge is not null; +select*from student where stuName like '%张%'; +select*from student where stuAddress like '%湖%'; +select*from student where stuName like'张_%'; +select*from student where stuName like'__俊%'; +select*from student order by stuAge desc; +select*from student order by stuAge desc,stuNO asc; +select top 1*from exam order by writtenExam desc; +select top 1*from exam order by labExam asc; +select stuAddress, avg(stuAge) 平均年龄 from student group by stuAddress; +select sum(stuAge) from student group by stuSex; +select stuAddress,sum(stuAge) 年龄总和,avg(stuAge) 平均年龄 from student group by stuAddress, stuSex; + + + diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/zy2.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/zy2.sql" new file mode 100644 index 0000000000000000000000000000000000000000..e61610b8dc4349d362d06fa01060ce11712852af --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\205\255\346\254\241\344\275\234\344\270\232/zy2.sql" @@ -0,0 +1,54 @@ +create database zy2; +go + +use zy2; +create table orders( +orderID int primary key, +orderDate datetime +); + +create table item( +itemId int identity(1,1), +orderid int, +itemType nvarchar(33), +itemName nvarchar(33), +theNumber int, +theMoney money +); + +insert into orders(orderID,orderDate) + values(1,'2008-01-12 00:00:00.000' ), + (2,'2008-02-10 00:00:00.000'), + (3,'2008-02-15 00:00:00.000'), + (4,'2008-03-10 00:00:00.000'); + +insert into item(orderid,itemType,itemName,theNumber,theMoney) + values(1,'文具','笔',72,2), + (1,'文具','尺',10,1), + (1,'体育用品','篮球',1,56), + (2,'文具','笔',36,2), + (2,'文具','固体胶',20,3), + (2,'日常用品','透明胶',2,1), + (2,'体育用品','羽毛球',20,3), + (3,'文具','订书机',20,3), + (3,'文具','订书针',10,3), + (3,'文具','裁纸刀',5,5), + (4,'文具','笔',20,2), + (4,'文具','信纸',50,1), + (4,'日常用品','毛巾',4,5), + (4,'日常用品','透明胶',30,1), + (4,'体育用品','羽毛球',20,3); + + --1.查询所有订单订购的所有物品数量总和 + select sum(theNumber) 数量总和 from item; +--2.查询订单编号小于3的,平均单价小于10 每个订单订购的所有物品的数量和以及平均单价 + select orderid, sum(theNumber) 物品的数量,avg(theMoney) 平均单价 from item where orderid<3 group by orderid having avg(theMoney)<10; +--3.查询平均单价小于10并且总数量大于 50 每个订单订购的所有物品数量和以及平均单价 +select avg(theMoney)平均单价,sum(theNumber)物品数量 from item having avg(theMoney)<10 and sum(theNumber)>50; +--4.查询每种类别的产品分别订购了几次: +select itemType 产品类别, count(itemType) from item group by itemType; +--5.查询每种类别的产品的订购总数量在100以上的订购总数量和平均单价 +select itemType 产品类别,avg(theMoney)平均单价,sum(theNumber)物品数量 from item group by itemType having sum(theNumber)>100 ; +--6.查询每种产品的订购次数,订购总数量和订购的平均单价,例如: +select itemType 产品类别,count(itemName) 订购次数,avg(theMoney)平均单价,sum(theNumber)物品数量 from item group by itemType; + diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\240\207\346\230\237\345\256\211.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\240\207\346\230\237\345\256\211.sql" new file mode 100644 index 0000000000000000000000000000000000000000..66529789d10ad44809bf133fdca344737a8e7f9c --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\274\240\346\240\207\346\230\237\345\256\211.sql" @@ -0,0 +1,61 @@ +create database lol; +go +use lol; +--用户信息表 +create table Users( +Userid int primary key, --用户ID +Username varchar(30), --用户名称 +Userpassword nvarchar(30), --密码 +Opentime datetime --创号时间 +); + +insert into Users(Userid,Username,Userpassword,Opentime) +values(1,'富强',123,'2004-03-03'), + (2,'Theshy',123,'2018-011-03'), + (3,'clerlove7',123,'2021-11-07'), + (4,'宝宝巴士',123,'2077-07-12'), + (5,'重振LPL荣光,我辈义不容辞',123,'2020-11-15'); + +--战绩信息表 +create table Recordinfo( +UseriD nvarchar(20), +Heroid int, +UserHero nvarchar(20), --使用英雄 +BattlesNumber int, --对战场次 +WinRate nvarchar(10),--胜率 +FighTtime datetime --对战时间 +); + +insert into Recordinfo(UserID,Heroid,UserHero,BattlesNumber,WinRate,FighTtime) +values (1,1,'亚索','100','0%','2023-03-23 16:46:00'), +(2,2,'卡莎','100','99%','2023-03-23 17:46:00'), +(3,3,'塞拉斯','100','0%','2023-03-24 16:36:00'), +(4,4,'派克','100','50%','2023-03-30 18:30:00'), +(5,5,'瑞兹','100','10%','2023-03-14 17:00:00') + +--英雄信息表 +create table Heroinfo( +Userid int, +Heroid int, --英雄编号 +Heroname nvarchar(30), --英雄名称 +Skinname nvarchar(30), --皮肤名称 +); + +insert into Heroinfo(Userid,Heroid,Heroname,Skinname) + values(1,1,'亚索','黑夜使者'), + (2,2,'卡莎','IG'), + (3,3,'塞拉斯','弗雷尔卓德'), + (4,4,'派克','至高天'), + (5,5,'瑞兹','至死不渝'), + (6,6,'李青','龙的传人'), + (7,7,'艾希','西部天使'), + (8,8,'艾克','真实伤害'), + (9,9,'德莱厄斯','神王'); + +--查询英雄信息 +select*from Heroinfo; +--查询‘Theshy’的账号信息 +select*from Users inner join Recordinfo on Users.Userid=Recordinfo.Userid where Username='Theshy'; +--查询英雄名字前一个字为‘艾’的英雄皮肤名称 +select Skinname 皮肤 from Heroinfo where Heroname like'艾_'; + diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/Program.cs" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/Program.cs" new file mode 100644 index 0000000000000000000000000000000000000000..03b37731b17be0b6ea8d6355c89a8e8a7c09051d --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/Program.cs" @@ -0,0 +1,69 @@ +锘縰sing System; + +namespace 鍩虹璇硶 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("鐪熸槸澶╀笂闄嶉瓟涓"); + Console.WriteLine("濡傚悓浜洪棿澶瞾绁"); + Console.WriteLine("杩欎釜璐惧厠鏂"); + Console.WriteLine("鐗"); + Console.WriteLine("閫"); + Console.WriteLine("--------------------"); + bool s1=true; + bool s2=false; + Console.WriteLine("s1"+s1); + Console.WriteLine("s2"+s2); + Console.WriteLine("--------------------"); + byte a1 = 0; + byte a2 = 255; + Console.WriteLine("a1"+a1); + Console.WriteLine("a2"+a2); + short b1 = 3; + short b2 = 4; + Console.WriteLine("b1"+b1); + Console.WriteLine("b2"+b2); + int c1 = 5; + int c2 = 6; + Console.WriteLine("c1"+c1); + Console.WriteLine("c2"+c2); + long d1 = 7; + long d2 = 8; + Console.WriteLine("d1"+d1); + Console.WriteLine("d2"+d2); + Console.WriteLine("--------------------"); + float e1 = -3.14f; + float e2 = 3.14f; + Console.WriteLine("e1"+e1); + Console.WriteLine("e2"+e2); + double f1 = -3.14; + double f2 = 3.14; + Console.WriteLine("f1"+f1); + Console.WriteLine("f2"+f2); + Console.WriteLine("--------------------"); + int a = 10; + int b = 20; + Console.WriteLine("a:" + a); + Console.WriteLine("b" + b); + int temp = a; + a = b; + b = temp; + Console.WriteLine("a"+a); + Console.WriteLine("b"+b); + Console.WriteLine("-------------------"); + int x = 100, y = 200; + int add = x + y; + int sub = x - y; + int mul = x * y; + int div=x / y; + Console.WriteLine("-------------------"); + double x1 = 100.8, y1 = 20.6; + double add1 = x1 + y1; + double sub1= x1 - y1; + double mul1 = x * y1; + double div1 = x / y1; + } + } +} diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/hellow word.PNG" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/hellow word.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..d71a7283221ed3e0ebc75dd3bb0ed16073dfb182 Binary files /dev/null and "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/hellow word.PNG" differ diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/hellow word.cs" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/hellow word.cs" new file mode 100644 index 0000000000000000000000000000000000000000..a864fc4b52941880d0e34017e01584076f69b8d8 --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/hellow word.cs" @@ -0,0 +1,16 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello Word!"); + } + } +} diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\227\245\346\234\237\345\207\275\346\225\260.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\227\245\346\234\237\345\207\275\346\225\260.sql" new file mode 100644 index 0000000000000000000000000000000000000000..495894be8bddff682cdc23c1be2af9e677428907 --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/\346\227\245\346\234\237\345\207\275\346\225\260.sql" @@ -0,0 +1,23 @@ +--日期函数练习 +---------------------- +--1.获取当前系统时间 +select getdate() +--2.获取本月的第一天 +select dateadd(month,datediff(month,0,getdate()),0) +--3.获取本月的最后一天 +select dateadd(month,datediff(month,0,getdate())+1,0)-1 +--3.获取下个月的第一天 +select dateadd(month,datediff(month,0,getdate())+1,0) +--4.获取本周的 第一天 +select dateadd(week,datediff(week,0,getdate()),-1) +--5.获取本周的最后一天 +select dateadd(week,datediff(week,0,getdate())+1,-1)-1 +--6.查询学生的出生年份信息 +select distinct year(StudentBirth) from Student +--7.查询学生信息:姓名,年龄(年龄用datediff函数进行计算) +select *,datediff(year,StudentBirth,getdate()) 年龄 from Student +--8.查询本月生日的学生信息:学号,姓名,出生日期,年龄 +select StudentId 学号,StudentName 姓名, StudentBirth 出生日期, +(year(getdate())-year(StudentBirth)) 年龄 from Student where month(StudentBirth)=month(getdate()) +--9.查询下个月生日的学生信息 +select * from Student where month(StudentBirth)=month(getdate())+1 \ No newline at end of file diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232.PNG" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232.PNG" new file mode 100644 index 0000000000000000000000000000000000000000..9c0ff8affbe72f5cd60bae9c393bafbb64dad401 Binary files /dev/null and "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232.PNG" differ diff --git "a/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232.sql" "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232.sql" new file mode 100644 index 0000000000000000000000000000000000000000..81d64d01e494dac8620b3aaa7a5d278750c02989 --- /dev/null +++ "b/49\345\274\240\346\240\207\346\230\237\345\256\211/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232/\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232.sql" @@ -0,0 +1,30 @@ +create database Bank; +go +use Bank; +--账号信息表 AccountInfo +create table Accountlnfo( +AccountId int primary key identity not null, --账户编号 +AccountCode varchar(20) unique not null, --身份证号码 +AccountPhone varchar(20) not null, --电话号码 +RealName varchar(20) not null, --真实姓名 +OpenTime smalldatetime default'getdate' not null, --开户时间 +); +--银行卡表 BankCard +create table BankCard( +CardNo varchar(30) primary key, --银行卡号 +AccountId int not null, --账户编号 +CardPwd varchar(30) not null, --银行密码 +CardBalance money default'0.00' not null, --银行卡余额 +CardState tinyint default'1' not null, --银行卡状态:1正常;2挂失;3冻结;4注销;5睡眠; +CardTime smalldatetime not null, --开卡时间 +foreign key(AccountId)references Accountlnfo(AccountId), +); +--交易信息表 CardExchange +create table CardExchange( +Exchangeld int primary key identity, --交易编号 +CardNo varchar(30) not null, --银行卡号 +MoneylnBank money not null check(MoneylnBank>='0'), --存钱金额 +MoneyOutBank money not null check(MoneyOutBank>='0'), --取钱金额 +ExchangeTime smalldatetime not null, --交易时间 +foreign key(CardNo)references BankCard (CardNo), +); diff --git "a/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" "b/\346\226\260\345\273\272\346\226\207\346\234\254\346\226\207\346\241\243.txt" deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000