Download presentation
Presentation is loading. Please wait.
Published byNora Davis Modified over 5 years ago
1
Database Quizz I Write down your answers in word document with file name highlighting your name, student number, and class. E.g “95002”+”_”+ “03 class”+”_”+”name”, like, “95002_03_Mike.doc”
2
Number 1(20%) Use one SQL statement to get the list of all the student names, whose every registered course has a score higher than 85. name course score Mike DataBase 81 Jane DataBase 86 Jane Math 90 Tonny DataBase 86 Tonny Math A. select distinct name from SC where name not in (select distinct name from SC where score<=85)
3
Number 2 (20%) Assume the student table has the following rows. Serial Number Sno Sname Cno Cname Score 1 Mike 0001 Math 99 2 John 0001 Math 89 3 Mike Math 99 Use one SQL statement to delete the records whose attributes are redundant except for Serial number. A. delete from tablename where seriel Number not in (select min(serial Number) from tablename group by Sno, Sname, Cname, Score)
4
Number 3(30%) Assume a database has the following tables. Teacher(Tno, Tname) describes the information concerning teachers Student(Sno,Sname,Sage,Ssex) stores the information about students Course(Cno,Cname,Tno) is the course table SC(Sno,Cno,score) has the scores 1. Use one SQL statement to get the list of student names, who at least registers one common course with student with Sno “95005” A. select distinct SC.Sno,Sname from Student,SC where Student.Sno=SC.Sno and Cno in (select Cno from SC where Sno=‘95005') 2. Use one SQL statement to get the complete list of students, who registers only one course. Print their student numbers and names and order the list by student number. A. select SC.Sno,Student.Sname,count(Cno) from SC ,Student where SC.Sno=Student.Sno group by SC.Sno ,Student.Sname having count(Cno)=1
5
3. Use one SQL statement to get the list of courses, each of which is registered by every student.
A. select Cno, Cname from Course where Cno in (select Cno from SC group by Cno having count(*) = (select count(*) from student))
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.