Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions