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 was the restaraunt id with the least amount of time spent?
assistant
SELECT Visits_Restaurant.ResID FROM Visits_Restaurant JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID GROUP BY Restaurant.ResID ORDER BY SUM( Visits_Restaurant.Spent ) ASC LIMIT 1 ;
human
Give the name of this restaraunt and sum of time spent.
assistant
SELECT Restaurant.ResName , SUM( Visits_Restaurant.Spent ) FROM Visits_Restaurant JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID GROUP BY Restaurant.ResID ORDER BY SUM( Visits_Restaurant.Spent ) ASC LIMIT 1 ;