Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a database schema with the following tables: CREATE TABLE Students ( StudentID INT PRIMARY KEY, Name VARCHAR ( 5 0 ) , Age INT,

Consider a database schema with the following tables:
CREATE TABLE Students (
StudentID INT PRIMARY KEY,
Name VARCHAR(50),
Age INT,
GPA FLOAT );
CREATE TABLE Courses (
CourseID INT PRIMARY KEY,
CourseName VARCHAR(50));
CREATE TABLE Enrollments (
EnrollmentID INT PRIMARY KEY,
StudentID INT,
CourseID INT,
Grade FLOAT,
FOREIGN KEY (StudentID) REFERENCES Students(StudentID),
FOREIGN KEY (CourseID) REFERENCES Courses(CourseID));
Solve the following SQL problems by nesting queries.
1. Write an SQL query to find the names of students who are enrolled in the course 'Mathematics' and have a GPA greater than 3.5.
2. Assuming the same database schema, write an SQL query to find the average GPA of students who have enrolled in the course 'Physics'.
3. Extend the previous query to find the average GPA of students who have enrolled in the course 'Physics' and whose age is less than 25.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions