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
What is the description of the restaurant type Sandwich?
assistant
SELECT ResTypeDescription FROM Restaurant_Type WHERE ResTypeName = 'Sandwich';
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
How many restaurant is the Sandwich type restaurant?
assistant
SELECT count(*) FROM Restaurant JOIN Type_Of_Restaurant ON Restaurant.ResID = Type_Of_Restaurant.ResID JOIN Restaurant_Type ON Type_Of_Restaurant.ResTypeID = Restaurant_Type.ResTypeID GROUP BY Type_Of_Restaurant.ResTypeID HAVING Restaurant_Type.ResTypeName = 'Sandwich'
human
Which restaurants have highest rating? List the restaurant name and its rating.
assistant
SELECT ResName , Rating FROM Restaurant ORDER BY Rating DESC LIMIT 1;
human
What is the address of the restaurant Subway?
assistant
SELECT Address FROM Restaurant WHERE ResName = 'Subway';
human
What is the rating of the restaurant Subway?
assistant
SELECT Rating FROM Restaurant WHERE ResName = "Subway" ;