In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the interview questions in the Java database?" in the operation of the actual case, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
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
This is the end of the content of "what are the interview questions for Java database". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.