当前位置:网站首页>Introduction to database system experiment report answer Experiment 6: advanced query of data table
Introduction to database system experiment report answer Experiment 6: advanced query of data table
2022-06-11 08:24:00 【kl_ xiao】
Experiment six : Data table advanced query
One 、 The experiment purpose
1. master SELECT The basic syntax of the statement and the expression method of query conditions ;
2. Master the connection query method of data table ;
3. Master the representation and use of nested queries ;
4. Master the representation and use of set query
Two 、 Experimental hours
2 Class hours
3、 ... and 、 The experimental requirements
1. understand SELECT The basic syntax format and execution method of the statement ;
2. Understand the representation and use of connection query ;
3. Master the methods of nested query and set query ;
4. Finish the experiment report ;
Four 、 Experimental content
By experiment 5 Database based , Please use T-SQL Statement implementation performs the following operations :
1. Search the first name in the list 2 The word is ‘ towards ’ Name and student number of the student and elective course number 、 Course name ;
select sname,XSKC.student.sno,XSKC.sc.cno,cname
from XSKC.student,XSKC.sc,XSKC.course
where XSKC.student.sno=XSKC.sc.sno and XSKC.sc.cno=XSKC.course.cno and sname like'_ towards %';

2. List of electives ‘ mathematics ’ perhaps ‘ College English ’ The student number of 、 full name 、 department 、 Elective course number and grade ;
select XSKC.student.sno,sname,sdept,XSKC.sc.cno,grade
from XSKC.student,XSKC.sc,XSKC.course
where XSKC.student.sno=XSKC.sc.sno and XSKC.sc.cno=XSKC.course.cno and XSKC.sc.cno='2'or XSKC.sc.cno='8';

3. Query and ‘ tension ’( Suppose the name is unique ) Information about all students of different ages ;
select*
from XSKC.student
where sage !=(
select sage
from XSKC.student
where sname=' tension ');

4. according to “ Student number , full name , department , Credits completed ” List the students' credits in the order of . Among them, the completed courses are divided into the sum of credits of courses that have passed the examination ;
select XSKC.student.sno,sname,sdept,sum(ccredit) Credits completed
from XSKC.student,XSKC.sc,XSKC.course
where XSKC.student.sno=XSKC.sc.sno and XSKC.sc.cno=XSKC.course.cno and XSKC.sc.grade>='60'
groupby XSKC.student.sno,XSKC.student.sname,XSKC.student.sdept

5. Find the student number of students who have taken at least one of the same elective courses as tension 、 Name and course number ;
select XSKC.student.sno,sname,cno
from XSKC.student,XSKC.sc
where XSKC.student.sno=XSKC.sc.sno and XSKC.sc.cno =any
(select cno from XSKC.sc,XSKC.student where XSKC.sc.sno=XSKC.student.sno and sname=' tension ')and sname !=' tension '

6. Query the course number of the course selected by only one student 、 Course name ;
select XSKC.sc.cno,cname
from XSKC.sc,XSKC.course
where XSKC.sc.cno=XSKC.course.cno
groupby XSKC.sc.cno,cname
havingcount(*)='1';

7. Use nested query to find out “ data structure ” Student number and name of the course ;
select XSKC.student.sno,sname
from XSKC.student,XSKC.sc
where cno =(select cno from XSKC.course where cname=' data structure ')

8. Use nested queries to query other departments whose age is less than CS The name of a student in the Department 、 Age and department ;
select sname,sage,sdept
from XSKC.student
where sage<any(select sage
from XSKC.student
where sdept='cs')
and sdept !='CS';

9. Use ANY、ALL Inquire about , List more than... In other departments WM The names of all the younger students in the Department ;
select sname
from XSKC.student
where sage<ALL(select sage
from XSKC.student
where sdept='WM')
and sdept !='WM';

10. Use join queries and nested queries, respectively , List and ‘ tension ’ Information about students in a department ;
Self connect :
select two.*
from XSKC.student as one,XSKC.student as two
where one.sdept=two.sdept and one.sname=' tension 'and two.sname !=' tension ';

nesting :
select*
from XSKC.student
where sdept =(select sdept
from XSKC.student
where sname=' tension ')
and sname !=' tension ';

11. List using set query CS The student number and name of the students of the Department and the students of female sex ;
select sname
from XSKC.student
where sdept ='CS'
union
select sname
from XSKC.student
where ssex =' Woman ';

12. List using set query CS Students of the Department are no older than 19 The intersection of a year old student 、 Difference set ;
intersection :
select*
from XSKC.student
where sdept ='CS'
intersect
select*
from XSKC.student
where sage <='19';

Difference set :
select*
from XSKC.student
where sdept ='CS'
except
select*
from XSKC.student
where sage <='19';

5、 ... and 、 The experimental steps
Command mode : stay 【SQL Server Management Studio】 Select... At the top left of the window 【 New query 】 Button , start-up SQL Editor window , Enter... At the cursor T-SQL sentence , single click 【 perform 】 Button .
边栏推荐
- 嵌入式软件面试问题总结
- [the most complete ENSP [installation diagram] in history!]
- Typescript class and interface, class and generic, interface merging
- Typescript unknown type
- (resolved) pychart debug error -unicode decodeerror: 'UTF-8' codec can't decode byte 0xe8 in position 1023
- Solve ('You must install pydot (`pip install pydot`) and install graphviz (see...) '‘ for plot_ model..
- Pycharm启动卡死,loading project
- (completely solved) dataframe assignment settingwithcopywarning: a value is trying to be set on a copy of a slice
- (the slow download speed of cifar10 in torchvision has been solved) how to download and use torchvision import
- 134. gas station
猜你喜欢

Solve cannot import name 'multiheadattention' from 'tensorflow keras. layers‘
![[the most complete ENSP [installation diagram] in history!]](/img/1a/7d50d6e5c06a5e3ce6acab16ddb638.jpg)
[the most complete ENSP [installation diagram] in history!]

(resolved) the tqdm progress bar in the Jupiter notebook does not update and display in one line, but scrolls down to output

go for it Easily manage all types of items with "flying items"

Xshell7 and xftp7 to continue using this program, you must apply the latest updates or use a new version

JS learning basics document Write write a line of text in the page

Deep understanding of add in argparse module_ Argument parameters (such as action)

SSM file upload and download

【 史上最全的ENSP【安装图解】!】

How CSDN reports plagiarized articles
随机推荐
bat 批处理单独环境打包
DAMENG 数据库登陆
How to find the complementary sequence of digraph
Pycharm启动卡死,loading project
Redis cluster in Linux system
【CVPR2022】QueryDet论文精读
TypeScript-枚举
Icml2022 interesting articles
Batch splice string
torch. roll
Js学习基础document.write在页面中写一行文字
用飞项进行目标管理,不做职场上的“无头苍蝇”
TypeScript-分布式条件类型
Solve cannot import name 'multiheadattention' from 'tensorflow keras. layers‘
Polymorphic interview questions
Installing MySQL and cluster operation on virtual machine in Linux system
DAMENG 用户管理
Niuke JS wrong question knowledge point record
Use guidelines in constraintlayout to limit the maximum width of controls
Js基础学习Script