Question
Using MySQL, Print the age of the oldest and youngest student(s) per department. Note that MySQL provides several functions for performing calculations on DATE. The
Using MySQL, Print the age of the oldest and youngest student(s) per department. Note that MySQL provides several functions for performing calculations on DATE. The function TIMESTAMDIFF() can be used to convert the date of birth to age. Several examples are available at https://dev.mysql.com/doc/refman/5.7/en/date-calculations.html
CREATE TABLE Students( stuID CHAR(10), stuName varchar(30), gender char(1), birthdate DATE, enterYear Year(4), gpa float(4,3), PRIMARY KEY(stuID));
CREATE TABLE Majors( deptName varchar(25), stuID CHAR(10), degreeProgram VARCHAR(40), attendSemester VARCHAR(15), attendYear YEAR(4), PRIMARY KEY(deptName,stuID), FOREIGN KEY(deptName) REFERENCES Departments(deptName), FOREIGN KEY(stuID) REFERENCES Students(stuID));
This is what I have so far:
SELECT Distinct age, deptName TIMESTAMPDIFF (YEAR, birthdate, CURDATE()) AS age FROM Student, Majors Where
Can you help me finish it?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started