Use SQL to write the following queries: a) Find the last names of students born after January 1, 2000 b) Find the student last names, dates and grades of exams they passed, where a grade was greater than or equal to 8 c) Find the first and last names of students who took to at least one exam from "Computer Science" programme d) List professor IDs of top 5 professors who teach the most courses e) Calculate the average credits for courses in each programme f) Find the surnames of students who have never taken an exam from “Mathematics” programme   a) SELECT last_name FROM Student WHERE date_of_birth < '2000-01-01'; (I assume that the type of date of birth in the table student is DATE) b)SELECT Student.last_name, Exam.exam_date, Exam.grade FROM Student JOIN Exam ON Student.student_id = Exam.student_id WHERE Exam.grade >= 8; c)SELECT Student.first_name, Student.last_name FROM Student JOIN Exam  ON Student.student_id = Exam.student_id JOIN Course  ON Exam.course_id = Course.course_id WHERE Course.programme = 'Computer Science'; d)SELECT professor_id, COUNT(course_id) AS course_count FROM Course GROUP BY professor_id ORDER BY course_count DESC LIMIT 5; e)SELECT programme, SUM(credits) / COUNT(course_id) FROM Course GROUP BY programme; f)SELECT Student.last_name FROM Student  LEFT JOIN Exam ON Student.student_id = Exam.student_id LEFT JOIN Course ON Exam.course_id = Course.course_id AND Course.programme = 'Mathematics'

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Use SQL to write the following queries:
a) Find the last names of students born after January 1, 2000
b) Find the student last names, dates and grades of exams they passed, where a grade was
greater than or equal to 8
c) Find the first and last names of students who took to at least one exam from "Computer
Science" programme
d) List professor IDs of top 5 professors who teach the most courses
e) Calculate the average credits for courses in each programme
f) Find the surnames of students who have never taken an exam from “Mathematics”
programme  

a) SELECT last_name
FROM Student
WHERE date_of_birth < '2000-01-01'; (I assume that the type of date of birth in the table student is DATE)
b)SELECT Student.last_name, Exam.exam_date, Exam.grade
FROM Student
JOIN Exam ON Student.student_id = Exam.student_id
WHERE Exam.grade >= 8;
c)SELECT Student.first_name, Student.last_name
FROM Student
JOIN Exam  ON Student.student_id = Exam.student_id
JOIN Course  ON Exam.course_id = Course.course_id
WHERE Course.programme = 'Computer Science';
d)SELECT professor_id, COUNT(course_id) AS course_count
FROM Course
GROUP BY professor_id
ORDER BY course_count DESC
LIMIT 5;
e)SELECT programme, SUM(credits) / COUNT(course_id)
FROM Course
GROUP BY programme;
f)SELECT Student.last_name
FROM Student 
LEFT JOIN Exam ON Student.student_id = Exam.student_id
LEFT JOIN Course ON Exam.course_id = Course.course_id
AND Course.programme = 'Mathematics'
WHERE Exam.exam_date IS NULL AND Exam.grade IS NULL; are these answers correct?

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Multiple table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education