human
Schema:
Student (StuID, LName, Fname, Age, Sex, Major, Advisor, city_code)
Video_Games (GameID, GName, GType)
Plays_Games (StuID, GameID, Hours_Played)
SportsInfo (StuID, SportName, HoursPerWeek, GamesPlayed, OnScholarship)
Please answer with SQL.
assistant
Sure, I understand.
human
Find the first name and age of the students who are playing both Football and Lacrosse.
assistant
SELECT fname , age FROM Student WHERE StuID IN (SELECT StuID FROM Sportsinfo WHERE SportName = 'Football' INTERSECT SELECT StuID FROM Sportsinfo WHERE SportName = 'Lacrosse')
human
Show first name for all students with major 600.
assistant
SELECT Fname FROM Student WHERE Major = 600
human
Show all student ids and the number of hours played.
assistant
SELECT Stuid , sum(hours_played) FROM Plays_games GROUP BY Stuid
human
Show all sport name and the number of students.
assistant
SELECT sportname , count(*) FROM Sportsinfo GROUP BY sportname
human
Show total hours per week and number of games played for students under 20.
assistant
SELECT sum(hoursperweek) , sum(gamesplayed) FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T2.age < 20
human
Show the average, minimum, and maximum age for different majors.
assistant
SELECT major , avg ( age ) , MIN( age ) , MAX( age ) FROM Student GROUP BY major ;