human
Schema:
Student (StuID, LName, Fname, Age, Sex, Major, Advisor, city_code)
Restaurant (ResID, ResName, Address, Rating)
Type_Of_Restaurant (ResID, ResTypeID)
Restaurant_Type (ResTypeID, ResTypeName, ResTypeDescription)
Visits_Restaurant (StuID, ResID, Time, Spent)
Please answer with SQL.
assistant
Sure, I understand.
human
How long does student Linda Smith spend on the restaurant in total?
assistant
SELECT sum(Spent) FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID WHERE Student.Fname = 'Linda' AND Student.Lname = 'Smith';
human
What is the gender of the student Linda Smith?
assistant
SELECT Sex FROM Student WHERE Fname = 'Linda' AND Lname = 'Smith';
human
What is the age of student Linda Smith?
assistant
SELECT Age FROM Student WHERE Fname = 'Linda' AND Lname = 'Smith';
human
Which city does student Linda Smith live in?
assistant
SELECT city_code FROM Student WHERE Fname = 'Linda' AND Lname = 'Smith';
human
How many times has the student Linda Smith visited Subway?
assistant
SELECT count(*) FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID WHERE Student.Fname = 'Linda' AND Student.Lname = 'Smith' AND Restaurant.ResName = 'Subway';
human
When did Linda Smith visit Subway?
assistant
SELECT TIME FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID WHERE Student.Fname = "Linda" AND Student.Lname = "Smith" AND Restaurant.ResName = "Subway" ;