Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the relevant interview questions in the database?

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what are the database-related interview questions". In the daily operation, I believe that many people have doubts about the database-related interview questions. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what are the database-related interview questions?" Next, please follow the editor to study!

Basic table structure:

Student (sno,sname,sage,ssex) student form

Course (cno,cname,tno) course schedule

Sc (sno,cno,score) score sheet

Teacher (tno,tname) teacher list

101, check the student numbers of all students whose grades in course 1 are higher than those in course 2

Select a.sno from

(select sno,score from sc where cno=1) a

(select sno,score from sc where cno=2) b

Where a.score > b.score and a.sno=b.sno

102, inquire about the student number and average score of the students whose grade point average is greater than 60

Select a.sno as "student number", avg (a.score) as "grade point average"

From

(select sno,score from sc) a

Group by sno having avg (a.score) > 60

103, check all students' student numbers, names, number of courses, and total grades.

Select a.sno as student number, b.sname as name

Number of courses selected by count (a.cno) as, total score of sum (a.score) as

From sc a, student b

Where a.sno = b.sno

Group by a.sno, b.sname

Or:

Selectstudent.sno as student number, student.sname as name

Number of courses selected by count (sc.cno) as, total score of sum (score) as

From student left Outer join sc on student.sno = sc.sno

Group by student.sno, sname

104, query the number of teachers surnamed "Zhang"

Selectcount (distinct (tname)) from teacher where tname like 'Zhang%'

Or:

Select tname as "name", count (distinct (tname)) as "number"

From teacher

Where tname like' Zhang%'

Group by tname

105, inquire about the student numbers and names of the students who have not taken the "Zhang San" teacher class.

Select student.sno,student.sname from student

Where sno not in (select distinct (sc.sno) from sc,course,teacher

Where sc.cno=course.cno and teacher.tno=course.tno and teacher.tname=' Zhang San')

106, query the student numbers and names of students who have taken both courses 1 and 2

Select sno, sname from student

Where sno in (select sno from sc where sc.cno = 1)

And sno in (select sno from sc where sc.cno = 2)

Or:

Selectc.sno, c.sname from

(select sno from sc where sc.cno = 1) a

(select sno from sc where sc.cno = 2) b

Student c

Where a.sno = b.sno and a.sno = c.sno

Or:

Select student.sno,student.sname from student,sc where student.sno=sc.sno and sc.cno=1

And exists (select * from sc as sc_2 where sc_2.sno=sc.sno and sc_2.cno=2)

107, look up the student numbers and names of all the students who have studied all the courses taught by teacher Li Si.

Select a.sno, a.sname from student a, sc b

Where a.sno = b.sno and b.cno in

(select c.cno from course c, teacher d where c.tno = d.tno and d.tname ='Li Si')

Or:

Select a.sno, a.sname from student a, sc b

(select c.cno from course c, teacher d where c.tno = d.tno and d.tname ='Li Si') e

Where a.sno = b.sno and b.cno = e.cno

108, check the student numbers and names of all students whose scores of course number 1 are higher than those of course number 2.

Select a.sno, a.sname from student a

(select sno, score from sc where cno = 1) b

(select sno, score from sc where cno = 2) c

Where b.score > c.score and b.sno = c.sno and a.sno = b.sno

109, check the student numbers and names of all students whose course scores are less than 60 points.

Select sno,sname from student

Where sno not in (select distinct sno from sc where score > 60)

110, query the student number and name of the student who has at least one course that is the same as that of the student with student number 1

Select distinct a.sno, a.sname

From student a, sc b

Where a.sno 1 and a.sno=b.sno and

B.cno in (select cno from sc where sno = 1)

Or:

Select s.sno,s.sname

From student s

(select sc.sno

From sc

Where sc.cno in (select sc1.cno from sc sc1 where sc1.sno=1) and sc.sno1

Group by sc.sno) R1

Where r1.sno=s.sno

At this point, the study of "what are the relevant interview questions in the database" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report