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
How many games are played for all students?
assistant
SELECT sum(gamesplayed) FROM Sportsinfo
human
How many video games exist?
assistant
SELECT count(*) FROM Video_games
human
Which game type has least number of games?
assistant
SELECT gtype FROM Video_games GROUP BY gtype ORDER BY count(*) LIMIT 1
human
Which game type has most number of games?
assistant
SELECT gtype FROM Video_games GROUP BY gtype ORDER BY count(*) DESC LIMIT 1
human
Show the game name that has most number of hours played.
assistant
SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid ORDER BY sum(hours_played) DESC LIMIT 1
human
What are the names of all the games that have been played for at least 1000 hours?
assistant
SELECT gname FROM Plays_games AS T1 JOIN Video_games AS T2 ON T1.gameid = T2.gameid GROUP BY T1.gameid HAVING SUM( hours_played ) >= 1000 ;