db_id
stringclasses
140 values
messages
listlengths
2
2
soccer_1
[ { "content": "Translate the following question to SQL: List the names of all left-footed players who have overall rating between 85 and 90.\n\nSchema: CREATE TABLE Player_Attributes (\n id INTEGER PRIMARY KEY,\n player_fifa_api_id INTEGER,\n player_api_id INTEGER,\n date TEXT,\n overall_rating INTEGER,\n potential INTEGER,\n preferred_foot TEXT,\n attacking_work_rate TEXT,\n defensive_work_rate TEXT,\n crossing INTEGER,\n finishing INTEGER,\n heading_accuracy INTEGER,\n short_passing INTEGER,\n volleys INTEGER,\n dribbling INTEGER,\n curve INTEGER,\n free_kick_accuracy INTEGER,\n long_passing INTEGER,\n ball_control INTEGER,\n acceleration INTEGER,\n sprint_speed INTEGER,\n agility INTEGER,\n reactions INTEGER,\n balance INTEGER,\n shot_power INTEGER,\n jumping INTEGER,\n stamina INTEGER,\n strength INTEGER,\n long_shots INTEGER,\n aggression INTEGER,\n interceptions INTEGER,\n positioning INTEGER,\n vision INTEGER,\n penalties INTEGER,\n marking INTEGER,\n standing_tackle INTEGER,\n sliding_tackle INTEGER,\n gk_diving INTEGER,\n gk_handling INTEGER,\n gk_kicking INTEGER,\n gk_positioning INTEGER,\n gk_reflexes INTEGER,\n FOREIGN KEY (player_api_id) REFERENCES Player(player_api_id),\n FOREIGN KEY (player_fifa_api_id) REFERENCES Player(player_fifa_api_id)\n);\n\nCREATE TABLE sqlite_sequence (\n name,\n seq\n);\n\nCREATE TABLE Player (\n id INTEGER PRIMARY KEY,\n player_api_id INTEGER,\n player_name TEXT,\n player_fifa_api_id INTEGER,\n birthday TEXT,\n height INTEGER,\n weight INTEGER,\n UNIQUE (player_fifa_api_id),\n UNIQUE (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER PRIMARY KEY,\n country_id INTEGER,\n name TEXT,\n UNIQUE (name),\n FOREIGN KEY (country_id) REFERENCES Country(id)\n);\n\nCREATE TABLE Country (\n id INTEGER PRIMARY KEY,\n name TEXT,\n UNIQUE (name)\n);\n\nCREATE TABLE Team (\n id INTEGER PRIMARY KEY,\n team_api_id INTEGER,\n team_fifa_api_id INTEGER,\n team_long_name TEXT,\n team_short_name TEXT,\n UNIQUE (team_api_id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER PRIMARY KEY,\n team_fifa_api_id INTEGER,\n team_api_id INTEGER,\n date TEXT,\n buildUpPlaySpeed INTEGER,\n buildUpPlaySpeedClass TEXT,\n buildUpPlayDribbling INTEGER,\n buildUpPlayDribblingClass TEXT,\n buildUpPlayPassing INTEGER,\n buildUpPlayPassingClass TEXT,\n buildUpPlayPositioningClass TEXT,\n chanceCreationPassing INTEGER,\n chanceCreationPassingClass TEXT,\n chanceCreationCrossing INTEGER,\n chanceCreationCrossingClass TEXT,\n chanceCreationShooting INTEGER,\n chanceCreationShootingClass TEXT,\n chanceCreationPositioningClass TEXT,\n defencePressure INTEGER,\n defencePressureClass TEXT,\n defenceAggression INTEGER,\n defenceAggressionClass TEXT,\n defenceTeamWidth INTEGER,\n defenceTeamWidthClass TEXT,\n defenceDefenderLineClass TEXT,\n FOREIGN KEY (team_api_id) REFERENCES Team(team_api_id),\n FOREIGN KEY (team_fifa_api_id) REFERENCES Team(team_fifa_api_id)\n);", "role": "user" }, { "content": "SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id WHERE T2.preferred_foot = \"left\" AND T2.overall_rating >= 85 AND T2.overall_rating <= 90", "role": "assistant" } ]
soccer_1
[ { "content": "Translate the following question to SQL: What is the average rating for right-footed players and left-footed players?\n\nSchema: CREATE TABLE Player_Attributes (\n id INTEGER PRIMARY KEY,\n player_fifa_api_id INTEGER,\n player_api_id INTEGER,\n date TEXT,\n overall_rating INTEGER,\n potential INTEGER,\n preferred_foot TEXT,\n attacking_work_rate TEXT,\n defensive_work_rate TEXT,\n crossing INTEGER,\n finishing INTEGER,\n heading_accuracy INTEGER,\n short_passing INTEGER,\n volleys INTEGER,\n dribbling INTEGER,\n curve INTEGER,\n free_kick_accuracy INTEGER,\n long_passing INTEGER,\n ball_control INTEGER,\n acceleration INTEGER,\n sprint_speed INTEGER,\n agility INTEGER,\n reactions INTEGER,\n balance INTEGER,\n shot_power INTEGER,\n jumping INTEGER,\n stamina INTEGER,\n strength INTEGER,\n long_shots INTEGER,\n aggression INTEGER,\n interceptions INTEGER,\n positioning INTEGER,\n vision INTEGER,\n penalties INTEGER,\n marking INTEGER,\n standing_tackle INTEGER,\n sliding_tackle INTEGER,\n gk_diving INTEGER,\n gk_handling INTEGER,\n gk_kicking INTEGER,\n gk_positioning INTEGER,\n gk_reflexes INTEGER,\n FOREIGN KEY (player_api_id) REFERENCES Player(player_api_id),\n FOREIGN KEY (player_fifa_api_id) REFERENCES Player(player_fifa_api_id)\n);\n\nCREATE TABLE sqlite_sequence (\n name,\n seq\n);\n\nCREATE TABLE Player (\n id INTEGER PRIMARY KEY,\n player_api_id INTEGER,\n player_name TEXT,\n player_fifa_api_id INTEGER,\n birthday TEXT,\n height INTEGER,\n weight INTEGER,\n UNIQUE (player_fifa_api_id),\n UNIQUE (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER PRIMARY KEY,\n country_id INTEGER,\n name TEXT,\n UNIQUE (name),\n FOREIGN KEY (country_id) REFERENCES Country(id)\n);\n\nCREATE TABLE Country (\n id INTEGER PRIMARY KEY,\n name TEXT,\n UNIQUE (name)\n);\n\nCREATE TABLE Team (\n id INTEGER PRIMARY KEY,\n team_api_id INTEGER,\n team_fifa_api_id INTEGER,\n team_long_name TEXT,\n team_short_name TEXT,\n UNIQUE (team_api_id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER PRIMARY KEY,\n team_fifa_api_id INTEGER,\n team_api_id INTEGER,\n date TEXT,\n buildUpPlaySpeed INTEGER,\n buildUpPlaySpeedClass TEXT,\n buildUpPlayDribbling INTEGER,\n buildUpPlayDribblingClass TEXT,\n buildUpPlayPassing INTEGER,\n buildUpPlayPassingClass TEXT,\n buildUpPlayPositioningClass TEXT,\n chanceCreationPassing INTEGER,\n chanceCreationPassingClass TEXT,\n chanceCreationCrossing INTEGER,\n chanceCreationCrossingClass TEXT,\n chanceCreationShooting INTEGER,\n chanceCreationShootingClass TEXT,\n chanceCreationPositioningClass TEXT,\n defencePressure INTEGER,\n defencePressureClass TEXT,\n defenceAggression INTEGER,\n defenceAggressionClass TEXT,\n defenceTeamWidth INTEGER,\n defenceTeamWidthClass TEXT,\n defenceDefenderLineClass TEXT,\n FOREIGN KEY (team_api_id) REFERENCES Team(team_api_id),\n FOREIGN KEY (team_fifa_api_id) REFERENCES Team(team_fifa_api_id)\n);", "role": "user" }, { "content": "SELECT preferred_foot , avg(overall_rating) FROM Player_Attributes GROUP BY preferred_foot", "role": "assistant" } ]
soccer_1
[ { "content": "Translate the following question to SQL: Of all players with an overall rating greater than 80, how many are right-footed and left-footed?\n\nSchema: CREATE TABLE Player_Attributes (\n id INTEGER PRIMARY KEY,\n player_fifa_api_id INTEGER,\n player_api_id INTEGER,\n date TEXT,\n overall_rating INTEGER,\n potential INTEGER,\n preferred_foot TEXT,\n attacking_work_rate TEXT,\n defensive_work_rate TEXT,\n crossing INTEGER,\n finishing INTEGER,\n heading_accuracy INTEGER,\n short_passing INTEGER,\n volleys INTEGER,\n dribbling INTEGER,\n curve INTEGER,\n free_kick_accuracy INTEGER,\n long_passing INTEGER,\n ball_control INTEGER,\n acceleration INTEGER,\n sprint_speed INTEGER,\n agility INTEGER,\n reactions INTEGER,\n balance INTEGER,\n shot_power INTEGER,\n jumping INTEGER,\n stamina INTEGER,\n strength INTEGER,\n long_shots INTEGER,\n aggression INTEGER,\n interceptions INTEGER,\n positioning INTEGER,\n vision INTEGER,\n penalties INTEGER,\n marking INTEGER,\n standing_tackle INTEGER,\n sliding_tackle INTEGER,\n gk_diving INTEGER,\n gk_handling INTEGER,\n gk_kicking INTEGER,\n gk_positioning INTEGER,\n gk_reflexes INTEGER,\n FOREIGN KEY (player_api_id) REFERENCES Player(player_api_id),\n FOREIGN KEY (player_fifa_api_id) REFERENCES Player(player_fifa_api_id)\n);\n\nCREATE TABLE sqlite_sequence (\n name,\n seq\n);\n\nCREATE TABLE Player (\n id INTEGER PRIMARY KEY,\n player_api_id INTEGER,\n player_name TEXT,\n player_fifa_api_id INTEGER,\n birthday TEXT,\n height INTEGER,\n weight INTEGER,\n UNIQUE (player_fifa_api_id),\n UNIQUE (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER PRIMARY KEY,\n country_id INTEGER,\n name TEXT,\n UNIQUE (name),\n FOREIGN KEY (country_id) REFERENCES Country(id)\n);\n\nCREATE TABLE Country (\n id INTEGER PRIMARY KEY,\n name TEXT,\n UNIQUE (name)\n);\n\nCREATE TABLE Team (\n id INTEGER PRIMARY KEY,\n team_api_id INTEGER,\n team_fifa_api_id INTEGER,\n team_long_name TEXT,\n team_short_name TEXT,\n UNIQUE (team_api_id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER PRIMARY KEY,\n team_fifa_api_id INTEGER,\n team_api_id INTEGER,\n date TEXT,\n buildUpPlaySpeed INTEGER,\n buildUpPlaySpeedClass TEXT,\n buildUpPlayDribbling INTEGER,\n buildUpPlayDribblingClass TEXT,\n buildUpPlayPassing INTEGER,\n buildUpPlayPassingClass TEXT,\n buildUpPlayPositioningClass TEXT,\n chanceCreationPassing INTEGER,\n chanceCreationPassingClass TEXT,\n chanceCreationCrossing INTEGER,\n chanceCreationCrossingClass TEXT,\n chanceCreationShooting INTEGER,\n chanceCreationShootingClass TEXT,\n chanceCreationPositioningClass TEXT,\n defencePressure INTEGER,\n defencePressureClass TEXT,\n defenceAggression INTEGER,\n defenceAggressionClass TEXT,\n defenceTeamWidth INTEGER,\n defenceTeamWidthClass TEXT,\n defenceDefenderLineClass TEXT,\n FOREIGN KEY (team_api_id) REFERENCES Team(team_api_id),\n FOREIGN KEY (team_fifa_api_id) REFERENCES Team(team_fifa_api_id)\n);", "role": "user" }, { "content": "SELECT preferred_foot , count(*) FROM Player_Attributes WHERE overall_rating > 80 GROUP BY preferred_foot", "role": "assistant" } ]
soccer_1
[ { "content": "Translate the following question to SQL: List all of the player ids with a height of at least 180cm and an overall rating higher than 85.\n\nSchema: CREATE TABLE Player_Attributes (\n id INTEGER PRIMARY KEY,\n player_fifa_api_id INTEGER,\n player_api_id INTEGER,\n date TEXT,\n overall_rating INTEGER,\n potential INTEGER,\n preferred_foot TEXT,\n attacking_work_rate TEXT,\n defensive_work_rate TEXT,\n crossing INTEGER,\n finishing INTEGER,\n heading_accuracy INTEGER,\n short_passing INTEGER,\n volleys INTEGER,\n dribbling INTEGER,\n curve INTEGER,\n free_kick_accuracy INTEGER,\n long_passing INTEGER,\n ball_control INTEGER,\n acceleration INTEGER,\n sprint_speed INTEGER,\n agility INTEGER,\n reactions INTEGER,\n balance INTEGER,\n shot_power INTEGER,\n jumping INTEGER,\n stamina INTEGER,\n strength INTEGER,\n long_shots INTEGER,\n aggression INTEGER,\n interceptions INTEGER,\n positioning INTEGER,\n vision INTEGER,\n penalties INTEGER,\n marking INTEGER,\n standing_tackle INTEGER,\n sliding_tackle INTEGER,\n gk_diving INTEGER,\n gk_handling INTEGER,\n gk_kicking INTEGER,\n gk_positioning INTEGER,\n gk_reflexes INTEGER,\n FOREIGN KEY (player_api_id) REFERENCES Player(player_api_id),\n FOREIGN KEY (player_fifa_api_id) REFERENCES Player(player_fifa_api_id)\n);\n\nCREATE TABLE sqlite_sequence (\n name,\n seq\n);\n\nCREATE TABLE Player (\n id INTEGER PRIMARY KEY,\n player_api_id INTEGER,\n player_name TEXT,\n player_fifa_api_id INTEGER,\n birthday TEXT,\n height INTEGER,\n weight INTEGER,\n UNIQUE (player_fifa_api_id),\n UNIQUE (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER PRIMARY KEY,\n country_id INTEGER,\n name TEXT,\n UNIQUE (name),\n FOREIGN KEY (country_id) REFERENCES Country(id)\n);\n\nCREATE TABLE Country (\n id INTEGER PRIMARY KEY,\n name TEXT,\n UNIQUE (name)\n);\n\nCREATE TABLE Team (\n id INTEGER PRIMARY KEY,\n team_api_id INTEGER,\n team_fifa_api_id INTEGER,\n team_long_name TEXT,\n team_short_name TEXT,\n UNIQUE (team_api_id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER PRIMARY KEY,\n team_fifa_api_id INTEGER,\n team_api_id INTEGER,\n date TEXT,\n buildUpPlaySpeed INTEGER,\n buildUpPlaySpeedClass TEXT,\n buildUpPlayDribbling INTEGER,\n buildUpPlayDribblingClass TEXT,\n buildUpPlayPassing INTEGER,\n buildUpPlayPassingClass TEXT,\n buildUpPlayPositioningClass TEXT,\n chanceCreationPassing INTEGER,\n chanceCreationPassingClass TEXT,\n chanceCreationCrossing INTEGER,\n chanceCreationCrossingClass TEXT,\n chanceCreationShooting INTEGER,\n chanceCreationShootingClass TEXT,\n chanceCreationPositioningClass TEXT,\n defencePressure INTEGER,\n defencePressureClass TEXT,\n defenceAggression INTEGER,\n defenceAggressionClass TEXT,\n defenceTeamWidth INTEGER,\n defenceTeamWidthClass TEXT,\n defenceDefenderLineClass TEXT,\n FOREIGN KEY (team_api_id) REFERENCES Team(team_api_id),\n FOREIGN KEY (team_fifa_api_id) REFERENCES Team(team_fifa_api_id)\n);", "role": "user" }, { "content": "SELECT player_api_id FROM Player WHERE height >= 180 INTERSECT SELECT player_api_id FROM Player_Attributes WHERE overall_rating > 85", "role": "assistant" } ]
soccer_1
[ { "content": "Translate the following question to SQL: List all of the ids for left-footed players with a height between 180cm and 190cm.\n\nSchema: CREATE TABLE Player_Attributes (\n id INTEGER PRIMARY KEY,\n player_fifa_api_id INTEGER,\n player_api_id INTEGER,\n date TEXT,\n overall_rating INTEGER,\n potential INTEGER,\n preferred_foot TEXT,\n attacking_work_rate TEXT,\n defensive_work_rate TEXT,\n crossing INTEGER,\n finishing INTEGER,\n heading_accuracy INTEGER,\n short_passing INTEGER,\n volleys INTEGER,\n dribbling INTEGER,\n curve INTEGER,\n free_kick_accuracy INTEGER,\n long_passing INTEGER,\n ball_control INTEGER,\n acceleration INTEGER,\n sprint_speed INTEGER,\n agility INTEGER,\n reactions INTEGER,\n balance INTEGER,\n shot_power INTEGER,\n jumping INTEGER,\n stamina INTEGER,\n strength INTEGER,\n long_shots INTEGER,\n aggression INTEGER,\n interceptions INTEGER,\n positioning INTEGER,\n vision INTEGER,\n penalties INTEGER,\n marking INTEGER,\n standing_tackle INTEGER,\n sliding_tackle INTEGER,\n gk_diving INTEGER,\n gk_handling INTEGER,\n gk_kicking INTEGER,\n gk_positioning INTEGER,\n gk_reflexes INTEGER,\n FOREIGN KEY (player_api_id) REFERENCES Player(player_api_id),\n FOREIGN KEY (player_fifa_api_id) REFERENCES Player(player_fifa_api_id)\n);\n\nCREATE TABLE sqlite_sequence (\n name,\n seq\n);\n\nCREATE TABLE Player (\n id INTEGER PRIMARY KEY,\n player_api_id INTEGER,\n player_name TEXT,\n player_fifa_api_id INTEGER,\n birthday TEXT,\n height INTEGER,\n weight INTEGER,\n UNIQUE (player_fifa_api_id),\n UNIQUE (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER PRIMARY KEY,\n country_id INTEGER,\n name TEXT,\n UNIQUE (name),\n FOREIGN KEY (country_id) REFERENCES Country(id)\n);\n\nCREATE TABLE Country (\n id INTEGER PRIMARY KEY,\n name TEXT,\n UNIQUE (name)\n);\n\nCREATE TABLE Team (\n id INTEGER PRIMARY KEY,\n team_api_id INTEGER,\n team_fifa_api_id INTEGER,\n team_long_name TEXT,\n team_short_name TEXT,\n UNIQUE (team_api_id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER PRIMARY KEY,\n team_fifa_api_id INTEGER,\n team_api_id INTEGER,\n date TEXT,\n buildUpPlaySpeed INTEGER,\n buildUpPlaySpeedClass TEXT,\n buildUpPlayDribbling INTEGER,\n buildUpPlayDribblingClass TEXT,\n buildUpPlayPassing INTEGER,\n buildUpPlayPassingClass TEXT,\n buildUpPlayPositioningClass TEXT,\n chanceCreationPassing INTEGER,\n chanceCreationPassingClass TEXT,\n chanceCreationCrossing INTEGER,\n chanceCreationCrossingClass TEXT,\n chanceCreationShooting INTEGER,\n chanceCreationShootingClass TEXT,\n chanceCreationPositioningClass TEXT,\n defencePressure INTEGER,\n defencePressureClass TEXT,\n defenceAggression INTEGER,\n defenceAggressionClass TEXT,\n defenceTeamWidth INTEGER,\n defenceTeamWidthClass TEXT,\n defenceDefenderLineClass TEXT,\n FOREIGN KEY (team_api_id) REFERENCES Team(team_api_id),\n FOREIGN KEY (team_fifa_api_id) REFERENCES Team(team_fifa_api_id)\n);", "role": "user" }, { "content": "SELECT player_api_id FROM Player WHERE height >= 180 AND height <= 190 INTERSECT SELECT player_api_id FROM Player_Attributes WHERE preferred_foot = \"left\"", "role": "assistant" } ]
soccer_1
[ { "content": "Translate the following question to SQL: Who are the top 3 players in terms of overall rating?\n\nSchema: CREATE TABLE Player_Attributes (\n id INTEGER PRIMARY KEY,\n player_fifa_api_id INTEGER,\n player_api_id INTEGER,\n date TEXT,\n overall_rating INTEGER,\n potential INTEGER,\n preferred_foot TEXT,\n attacking_work_rate TEXT,\n defensive_work_rate TEXT,\n crossing INTEGER,\n finishing INTEGER,\n heading_accuracy INTEGER,\n short_passing INTEGER,\n volleys INTEGER,\n dribbling INTEGER,\n curve INTEGER,\n free_kick_accuracy INTEGER,\n long_passing INTEGER,\n ball_control INTEGER,\n acceleration INTEGER,\n sprint_speed INTEGER,\n agility INTEGER,\n reactions INTEGER,\n balance INTEGER,\n shot_power INTEGER,\n jumping INTEGER,\n stamina INTEGER,\n strength INTEGER,\n long_shots INTEGER,\n aggression INTEGER,\n interceptions INTEGER,\n positioning INTEGER,\n vision INTEGER,\n penalties INTEGER,\n marking INTEGER,\n standing_tackle INTEGER,\n sliding_tackle INTEGER,\n gk_diving INTEGER,\n gk_handling INTEGER,\n gk_kicking INTEGER,\n gk_positioning INTEGER,\n gk_reflexes INTEGER,\n FOREIGN KEY (player_api_id) REFERENCES Player(player_api_id),\n FOREIGN KEY (player_fifa_api_id) REFERENCES Player(player_fifa_api_id)\n);\n\nCREATE TABLE sqlite_sequence (\n name,\n seq\n);\n\nCREATE TABLE Player (\n id INTEGER PRIMARY KEY,\n player_api_id INTEGER,\n player_name TEXT,\n player_fifa_api_id INTEGER,\n birthday TEXT,\n height INTEGER,\n weight INTEGER,\n UNIQUE (player_fifa_api_id),\n UNIQUE (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER PRIMARY KEY,\n country_id INTEGER,\n name TEXT,\n UNIQUE (name),\n FOREIGN KEY (country_id) REFERENCES Country(id)\n);\n\nCREATE TABLE Country (\n id INTEGER PRIMARY KEY,\n name TEXT,\n UNIQUE (name)\n);\n\nCREATE TABLE Team (\n id INTEGER PRIMARY KEY,\n team_api_id INTEGER,\n team_fifa_api_id INTEGER,\n team_long_name TEXT,\n team_short_name TEXT,\n UNIQUE (team_api_id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER PRIMARY KEY,\n team_fifa_api_id INTEGER,\n team_api_id INTEGER,\n date TEXT,\n buildUpPlaySpeed INTEGER,\n buildUpPlaySpeedClass TEXT,\n buildUpPlayDribbling INTEGER,\n buildUpPlayDribblingClass TEXT,\n buildUpPlayPassing INTEGER,\n buildUpPlayPassingClass TEXT,\n buildUpPlayPositioningClass TEXT,\n chanceCreationPassing INTEGER,\n chanceCreationPassingClass TEXT,\n chanceCreationCrossing INTEGER,\n chanceCreationCrossingClass TEXT,\n chanceCreationShooting INTEGER,\n chanceCreationShootingClass TEXT,\n chanceCreationPositioningClass TEXT,\n defencePressure INTEGER,\n defencePressureClass TEXT,\n defenceAggression INTEGER,\n defenceAggressionClass TEXT,\n defenceTeamWidth INTEGER,\n defenceTeamWidthClass TEXT,\n defenceDefenderLineClass TEXT,\n FOREIGN KEY (team_api_id) REFERENCES Team(team_api_id),\n FOREIGN KEY (team_fifa_api_id) REFERENCES Team(team_fifa_api_id)\n);", "role": "user" }, { "content": "SELECT DISTINCT T1.player_name FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id ORDER BY overall_rating DESC LIMIT 3", "role": "assistant" } ]
soccer_1
[ { "content": "Translate the following question to SQL: List the names and birthdays of the top five players in terms of potential.\n\nSchema: CREATE TABLE Player_Attributes (\n id INTEGER PRIMARY KEY,\n player_fifa_api_id INTEGER,\n player_api_id INTEGER,\n date TEXT,\n overall_rating INTEGER,\n potential INTEGER,\n preferred_foot TEXT,\n attacking_work_rate TEXT,\n defensive_work_rate TEXT,\n crossing INTEGER,\n finishing INTEGER,\n heading_accuracy INTEGER,\n short_passing INTEGER,\n volleys INTEGER,\n dribbling INTEGER,\n curve INTEGER,\n free_kick_accuracy INTEGER,\n long_passing INTEGER,\n ball_control INTEGER,\n acceleration INTEGER,\n sprint_speed INTEGER,\n agility INTEGER,\n reactions INTEGER,\n balance INTEGER,\n shot_power INTEGER,\n jumping INTEGER,\n stamina INTEGER,\n strength INTEGER,\n long_shots INTEGER,\n aggression INTEGER,\n interceptions INTEGER,\n positioning INTEGER,\n vision INTEGER,\n penalties INTEGER,\n marking INTEGER,\n standing_tackle INTEGER,\n sliding_tackle INTEGER,\n gk_diving INTEGER,\n gk_handling INTEGER,\n gk_kicking INTEGER,\n gk_positioning INTEGER,\n gk_reflexes INTEGER,\n FOREIGN KEY (player_api_id) REFERENCES Player(player_api_id),\n FOREIGN KEY (player_fifa_api_id) REFERENCES Player(player_fifa_api_id)\n);\n\nCREATE TABLE sqlite_sequence (\n name,\n seq\n);\n\nCREATE TABLE Player (\n id INTEGER PRIMARY KEY,\n player_api_id INTEGER,\n player_name TEXT,\n player_fifa_api_id INTEGER,\n birthday TEXT,\n height INTEGER,\n weight INTEGER,\n UNIQUE (player_fifa_api_id),\n UNIQUE (player_api_id)\n);\n\nCREATE TABLE League (\n id INTEGER PRIMARY KEY,\n country_id INTEGER,\n name TEXT,\n UNIQUE (name),\n FOREIGN KEY (country_id) REFERENCES Country(id)\n);\n\nCREATE TABLE Country (\n id INTEGER PRIMARY KEY,\n name TEXT,\n UNIQUE (name)\n);\n\nCREATE TABLE Team (\n id INTEGER PRIMARY KEY,\n team_api_id INTEGER,\n team_fifa_api_id INTEGER,\n team_long_name TEXT,\n team_short_name TEXT,\n UNIQUE (team_api_id)\n);\n\nCREATE TABLE Team_Attributes (\n id INTEGER PRIMARY KEY,\n team_fifa_api_id INTEGER,\n team_api_id INTEGER,\n date TEXT,\n buildUpPlaySpeed INTEGER,\n buildUpPlaySpeedClass TEXT,\n buildUpPlayDribbling INTEGER,\n buildUpPlayDribblingClass TEXT,\n buildUpPlayPassing INTEGER,\n buildUpPlayPassingClass TEXT,\n buildUpPlayPositioningClass TEXT,\n chanceCreationPassing INTEGER,\n chanceCreationPassingClass TEXT,\n chanceCreationCrossing INTEGER,\n chanceCreationCrossingClass TEXT,\n chanceCreationShooting INTEGER,\n chanceCreationShootingClass TEXT,\n chanceCreationPositioningClass TEXT,\n defencePressure INTEGER,\n defencePressureClass TEXT,\n defenceAggression INTEGER,\n defenceAggressionClass TEXT,\n defenceTeamWidth INTEGER,\n defenceTeamWidthClass TEXT,\n defenceDefenderLineClass TEXT,\n FOREIGN KEY (team_api_id) REFERENCES Team(team_api_id),\n FOREIGN KEY (team_fifa_api_id) REFERENCES Team(team_fifa_api_id)\n);", "role": "user" }, { "content": "SELECT DISTINCT T1.player_name , T1.birthday FROM Player AS T1 JOIN Player_Attributes AS T2 ON T1.player_api_id = T2.player_api_id ORDER BY potential DESC LIMIT 5", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: How many performances are there?\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT count(*) FROM performance", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: List the hosts of performances in ascending order of attendance.\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT HOST FROM performance ORDER BY Attendance ASC", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: What are the dates and locations of performances?\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT Date , LOCATION FROM performance", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: Show the attendances of the performances at location \"TD Garden\" or \"Bell Centre\"\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT Attendance FROM performance WHERE LOCATION = \"TD Garden\" OR LOCATION = \"Bell Centre\"", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: What is the average number of attendees for performances?\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT avg(Attendance) FROM performance", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: What is the date of the performance with the highest number of attendees?\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT Date FROM performance ORDER BY Attendance DESC LIMIT 1", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: Show different locations and the number of performances at each location.\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT LOCATION , COUNT(*) FROM performance GROUP BY LOCATION", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: Show the most common location of performances.\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT LOCATION FROM performance GROUP BY LOCATION ORDER BY COUNT(*) DESC LIMIT 1", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: Show the locations that have at least two performances.\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT LOCATION FROM performance GROUP BY LOCATION HAVING COUNT(*) >= 2", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: Show the locations that have both performances with more than 2000 attendees and performances with less than 1000 attendees.\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT LOCATION FROM performance WHERE Attendance > 2000 INTERSECT SELECT LOCATION FROM performance WHERE Attendance < 1000", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: Show the names of members and the location of the performances they attended.\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT T2.Name , T3.Location FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID = T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID = T3.Performance_ID", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: Show the names of members and the location of performances they attended in ascending alphabetical order of their names.\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT T2.Name , T3.Location FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID = T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID = T3.Performance_ID ORDER BY T2.Name ASC", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: Show the dates of performances with attending members whose roles are \"Violin\".\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT T3.Date FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID = T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID = T3.Performance_ID WHERE T2.Role = \"Violin\"", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: Show the names of members and the dates of performances they attended in descending order of attendance of the performances.\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT T2.Name , T3.Date FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID = T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID = T3.Performance_ID ORDER BY T3.Attendance DESC", "role": "assistant" } ]
performance_attendance
[ { "content": "Translate the following question to SQL: List the names of members who did not attend any performance.\n\nSchema: CREATE TABLE member (\n Member_ID TEXT PRIMARY KEY,\n Name TEXT,\n Nationality TEXT,\n Role TEXT,\n UNIQUE (Member_ID)\n);\n\nCREATE TABLE performance (\n Performance_ID REAL PRIMARY KEY,\n Date TEXT,\n Host TEXT,\n Location TEXT,\n Attendance INT,\n UNIQUE (Performance_ID)\n);\n\nCREATE TABLE member_attendance (\n Member_ID INT PRIMARY KEY,\n Performance_ID INT PRIMARY KEY,\n Num_of_Pieces INT,\n PRIMARY KEY (Member_ID, Performance_ID),\n UNIQUE (Member_ID, Performance_ID),\n FOREIGN KEY (Performance_ID) REFERENCES performance(Performance_ID),\n FOREIGN KEY (Member_ID) REFERENCES member(Member_ID)\n);", "role": "user" }, { "content": "SELECT Name FROM member WHERE Member_ID NOT IN (SELECT Member_ID FROM member_attendance)", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the buildings which have rooms with capacity more than 50.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT DISTINCT building FROM classroom WHERE capacity > 50", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the distinct buildings with capacities of greater than 50?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT DISTINCT building FROM classroom WHERE capacity > 50", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Count the number of rooms that are not in the Lamberton building.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) FROM classroom WHERE building != 'Lamberton'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many classrooms are not in Lamberton?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) FROM classroom WHERE building != 'Lamberton'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What is the name and building of the departments whose budget is more than the average budget?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name , building FROM department WHERE budget > (SELECT avg(budget) FROM department)", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Give the name and building of the departments with greater than average budget.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name , building FROM department WHERE budget > (SELECT avg(budget) FROM department)", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the room number of the rooms which can sit 50 to 100 students and their buildings.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT building , room_number FROM classroom WHERE capacity BETWEEN 50 AND 100", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the room numbers and corresponding buildings for classrooms which can seat between 50 to 100 students?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT building , room_number FROM classroom WHERE capacity BETWEEN 50 AND 100", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the name and building of the department with the highest budget.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name , building FROM department ORDER BY budget DESC LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What is the department name and corresponding building for the department with the greatest budget?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name , building FROM department ORDER BY budget DESC LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What is the name of the student who has the highest total credits in the History department.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT name FROM student WHERE dept_name = 'History' ORDER BY tot_cred DESC LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Give the name of the student in the History department with the most credits.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT name FROM student WHERE dept_name = 'History' ORDER BY tot_cred DESC LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many rooms does the Lamberton building have?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) FROM classroom WHERE building = 'Lamberton'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Count the number of classrooms in Lamberton.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) FROM classroom WHERE building = 'Lamberton'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many students have advisors?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(DISTINCT s_id) FROM advisor", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Count the number of students who have advisors.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(DISTINCT s_id) FROM advisor", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many departments offer courses?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(DISTINCT dept_name) FROM course", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Count the number of departments which offer courses.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(DISTINCT dept_name) FROM course", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many different courses offered by Physics department?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(DISTINCT course_id) FROM course WHERE dept_name = 'Physics'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Count the number of courses in the Physics department.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(DISTINCT course_id) FROM course WHERE dept_name = 'Physics'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the title of courses that have two prerequisites?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.title FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING count(*) = 2", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the titles for courses with two prerequisites?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.title FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING count(*) = 2", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the title, credit, and department name of courses that have more than one prerequisites?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.title , T1.credits , T1.dept_name FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING count(*) > 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What is the title, credit value, and department name for courses with more than one prerequisite?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.title , T1.credits , T1.dept_name FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY T2.course_id HAVING count(*) > 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many courses that do not have prerequisite?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq)", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Count the number of courses without prerequisites.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq)", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the name of the courses that do not have any prerequisite?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq)", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the titles of courses without prerequisites?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq)", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many different instructors have taught some course?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT COUNT (DISTINCT id) FROM teaches", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Count the number of distinct instructors who have taught a course.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT COUNT (DISTINCT id) FROM teaches", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the total budgets of the Marketing or Finance department.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT sum(budget) FROM department WHERE dept_name = 'Marketing' OR dept_name = 'Finance'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What is the sum of budgets of the Marketing and Finance departments?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT sum(budget) FROM department WHERE dept_name = 'Marketing' OR dept_name = 'Finance'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the department name of the instructor whose name contains 'Soisalon'.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name FROM instructor WHERE name LIKE '%Soisalon%'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What is the name of the department with an instructure who has a name like 'Soisalon'?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name FROM instructor WHERE name LIKE '%Soisalon%'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many rooms whose capacity is less than 50 does the Lamberton building have?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) FROM classroom WHERE building = 'Lamberton' AND capacity < 50", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Count the number of rooms in Lamberton with capacity lower than 50.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) FROM classroom WHERE building = 'Lamberton' AND capacity < 50", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the name and budget of departments whose budgets are more than the average budget.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name , budget FROM department WHERE budget > (SELECT avg(budget) FROM department)", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the names and budgets of departments with budgets greater than the average?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name , budget FROM department WHERE budget > (SELECT avg(budget) FROM department)", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: what is the name of the instructor who is in Statistics department and earns the lowest salary?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT name FROM instructor WHERE dept_name = 'Statistics' ORDER BY salary LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Give the name of the lowest earning instructor in the Statistics department.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT name FROM instructor WHERE dept_name = 'Statistics' ORDER BY salary LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the title of course that is provided by both Statistics and Psychology departments.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course WHERE dept_name = 'Statistics' INTERSECT SELECT title FROM course WHERE dept_name = 'Psychology'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What is the title of a course that is listed in both the Statistics and Psychology departments?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course WHERE dept_name = 'Statistics' INTERSECT SELECT title FROM course WHERE dept_name = 'Psychology'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the title of course that is provided by Statistics but not Psychology departments.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course WHERE dept_name = 'Statistics' EXCEPT SELECT title FROM course WHERE dept_name = 'Psychology'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the titles of courses that are in the Statistics department but not the Psychology department?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course WHERE dept_name = 'Statistics' EXCEPT SELECT title FROM course WHERE dept_name = 'Psychology'", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the id of instructors who taught a class in Fall 2009 but not in Spring 2010.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT id FROM teaches WHERE semester = 'Fall' AND YEAR = 2009 EXCEPT SELECT id FROM teaches WHERE semester = 'Spring' AND YEAR = 2010", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the ids of instructors who taught in the Fall of 2009 but not in the Spring of 2010?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT id FROM teaches WHERE semester = 'Fall' AND YEAR = 2009 EXCEPT SELECT id FROM teaches WHERE semester = 'Spring' AND YEAR = 2010", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the name of students who took any class in the years of 2009 and 2010.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT DISTINCT T1.name FROM student AS T1 JOIN takes AS T2 ON T1.id = T2.id WHERE YEAR = 2009 OR YEAR = 2010", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the names of the students who took classes in 2009 or 2010?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT DISTINCT T1.name FROM student AS T1 JOIN takes AS T2 ON T1.id = T2.id WHERE YEAR = 2009 OR YEAR = 2010", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the names of the top 3 departments that provide the largest amount of courses?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name FROM course GROUP BY dept_name ORDER BY count(*) DESC LIMIT 3", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the names of the 3 departments with the most courses?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name FROM course GROUP BY dept_name ORDER BY count(*) DESC LIMIT 3", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the name of the department that offers the highest total credits?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name FROM course GROUP BY dept_name ORDER BY sum(credits) DESC LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What is the name of the department with the most credits?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name FROM course GROUP BY dept_name ORDER BY sum(credits) DESC LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: List the names of all courses ordered by their titles and credits.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course ORDER BY title , credits", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Given the titles of all courses, in order of titles and credits.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course ORDER BY title , credits", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Which department has the lowest budget?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name FROM department ORDER BY budget LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Give the name of the department with the lowest budget.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name FROM department ORDER BY budget LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: List the names and buildings of all departments sorted by the budget from large to small.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name , building FROM department ORDER BY budget DESC", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the names and buildings of the deparments, sorted by budget descending?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT dept_name , building FROM department ORDER BY budget DESC", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Who is the instructor with the highest salary?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT name FROM instructor ORDER BY salary DESC LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Give the name of the highest paid instructor.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT name FROM instructor ORDER BY salary DESC LIMIT 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: List the information of all instructors ordered by their salary in ascending order.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT * FROM instructor ORDER BY salary", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Give all information regarding instructors, in order of salary from least to greatest.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT * FROM instructor ORDER BY salary", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the name of the students and their department names sorted by their total credits in ascending order.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT name , dept_name FROM student ORDER BY tot_cred", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the names of students and their respective departments, ordered by number of credits from least to greatest?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT name , dept_name FROM student ORDER BY tot_cred", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: list in alphabetic order all course names and their instructors' names in year 2008.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.title , T3.name FROM course AS T1 JOIN teaches AS T2 ON T1.course_id = T2.course_id JOIN instructor AS T3 ON T2.id = T3.id WHERE YEAR = 2008 ORDER BY T1.title", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Show all titles and their instructors' names for courses in 2008, in alphabetical order by title.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.title , T3.name FROM course AS T1 JOIN teaches AS T2 ON T1.course_id = T2.course_id JOIN instructor AS T3 ON T2.id = T3.id WHERE YEAR = 2008 ORDER BY T1.title", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the name of instructors who are advising more than one student.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.name FROM instructor AS T1 JOIN advisor AS T2 ON T1.id = T2.i_id GROUP BY T2.i_id HAVING count(*) > 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the names of instructors who advise more than one student?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.name FROM instructor AS T1 JOIN advisor AS T2 ON T1.id = T2.i_id GROUP BY T2.i_id HAVING count(*) > 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the name of the students who have more than one advisor?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.name FROM student AS T1 JOIN advisor AS T2 ON T1.id = T2.s_id GROUP BY T2.s_id HAVING count(*) > 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the names of students who have more than one advisor?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT T1.name FROM student AS T1 JOIN advisor AS T2 ON T1.id = T2.s_id GROUP BY T2.s_id HAVING count(*) > 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the number of rooms with more than 50 capacity for each building.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) , building FROM classroom WHERE capacity > 50 GROUP BY building", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many rooms in each building have a capacity of over 50?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT count(*) , building FROM classroom WHERE capacity > 50 GROUP BY building", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the maximum and average capacity among rooms in each building.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT max(capacity) , avg(capacity) , building FROM classroom GROUP BY building", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the greatest and average capacity for rooms in each building?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT max(capacity) , avg(capacity) , building FROM classroom GROUP BY building", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the title of the course that is offered by more than one department.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course GROUP BY title HAVING count(*) > 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: What are the titles of courses that are offered in more than one department?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT title FROM course GROUP BY title HAVING count(*) > 1", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: Find the total credits of courses provided by different department.\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT sum(credits) , dept_name FROM course GROUP BY dept_name", "role": "assistant" } ]
college_2
[ { "content": "Translate the following question to SQL: How many total credits are offered by each department?\n\nSchema: CREATE TABLE classroom (\n building varchar(15) PRIMARY KEY,\n room_number varchar(7) PRIMARY KEY,\n capacity numeric(4,0),\n PRIMARY KEY (building, room_number),\n UNIQUE (building, room_number)\n);\n\nCREATE TABLE department (\n dept_name varchar(20) PRIMARY KEY,\n building varchar(15),\n budget numeric(12,2),\n UNIQUE (dept_name),\n budget\t\t numeric(12,2) check (budget > 0),\n);\n\nCREATE TABLE course (\n course_id varchar(8) PRIMARY KEY,\n title varchar(50),\n dept_name varchar(20),\n credits numeric(2,0),\n UNIQUE (course_id),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n credits\t\tnumeric(2,0) check (credits > 0),\n);\n\nCREATE TABLE instructor (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n salary numeric(8,2),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n salary\t\t\tnumeric(8,2) check (salary > 29000),\n);\n\nCREATE TABLE section (\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n building varchar(15),\n room_number varchar(7),\n time_slot_id varchar(4),\n PRIMARY KEY (course_id, sec_id, semester, year),\n UNIQUE (course_id, sec_id, semester, year),\n FOREIGN KEY (building) REFERENCES classroom(building),\n FOREIGN KEY (room_number) REFERENCES classroom(room_number),\n FOREIGN KEY (course_id) REFERENCES course(course_id),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer')),,\n year\t\t\tnumeric(4,0) check (year > 1701 and year < 2100),\n);\n\nCREATE TABLE teaches (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES instructor(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE student (\n ID varchar(5) PRIMARY KEY,\n name varchar(20) NOT NULL,\n dept_name varchar(20),\n tot_cred numeric(3,0),\n UNIQUE (ID),\n FOREIGN KEY (dept_name) REFERENCES department(dept_name),\n tot_cred\t\tnumeric(3,0) check (tot_cred >= 0),\n);\n\nCREATE TABLE takes (\n ID varchar(5) PRIMARY KEY,\n course_id varchar(8) PRIMARY KEY,\n sec_id varchar(8) PRIMARY KEY,\n semester varchar(6) PRIMARY KEY,\n year numeric(4,0) PRIMARY KEY,\n grade varchar(2),\n PRIMARY KEY (ID, course_id, sec_id, semester, year),\n UNIQUE (ID, course_id, sec_id, semester, year),\n FOREIGN KEY (ID) REFERENCES student(ID),\n FOREIGN KEY (course_id) REFERENCES section(course_id),\n FOREIGN KEY (sec_id) REFERENCES section(sec_id),\n FOREIGN KEY (semester) REFERENCES section(semester),\n FOREIGN KEY (year) REFERENCES section(year)\n);\n\nCREATE TABLE advisor (\n s_ID varchar(5) PRIMARY KEY,\n i_ID varchar(5),\n UNIQUE (s_ID),\n FOREIGN KEY (s_ID) REFERENCES student(ID),\n FOREIGN KEY (i_ID) REFERENCES instructor(ID)\n);\n\nCREATE TABLE time_slot (\n time_slot_id varchar(4) PRIMARY KEY,\n day varchar(1) PRIMARY KEY,\n start_hr numeric(2) PRIMARY KEY,\n start_min numeric(2) PRIMARY KEY,\n end_hr numeric(2),\n end_min numeric(2),\n PRIMARY KEY (time_slot_id, day, start_hr, start_min),\n UNIQUE (time_slot_id, day, start_hr, start_min),\n start_hr\t\tnumeric(2) check (start_hr >= 0 and start_hr < 24),,\n start_min\t\tnumeric(2) check (start_min >= 0 and start_min < 60),,\n end_hr\t\t\tnumeric(2) check (end_hr >= 0 and end_hr < 24),,\n end_min\t\tnumeric(2) check (end_min >= 0 and end_min < 60),\n);\n\nCREATE TABLE prereq (\n course_id varchar(8) PRIMARY KEY,\n prereq_id varchar(8) PRIMARY KEY,\n PRIMARY KEY (course_id, prereq_id),\n UNIQUE (course_id, prereq_id),\n FOREIGN KEY (prereq_id) REFERENCES course(course_id),\n FOREIGN KEY (course_id) REFERENCES course(course_id)\n);", "role": "user" }, { "content": "SELECT sum(credits) , dept_name FROM course GROUP BY dept_name", "role": "assistant" } ]