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
Show ids of students who play video game and play sports.
assistant
SELECT StuID FROM Sportsinfo INTERSECT SELECT StuID FROM Plays_games
human
How many video games exist?
assistant
SELECT count(*) FROM Video_games
human
Show ids of students who don't play video game.
assistant
SELECT StuID FROM Student EXCEPT SELECT StuID FROM Plays_games
human
How many students play sports?
assistant
SELECT count(DISTINCT StuID) FROM Sportsinfo
human
How many games are played for all students?
assistant
SELECT sum(gamesplayed) FROM Sportsinfo
human
How many different students play games?
assistant
SELECT COUNT( DISTINCT StuID ) FROM Plays_games ;