Hello! Can you provide me with the time spent in all restaurants by Linda Smith?
select sum ( spent ) from student join visits_restaurant on student.stuid = visits_restaurant.stuid where student.fname = "Linda" and student.lname = "Smith"
Are there any other students with the same city code as Linda Smith?
select * from student where city_code = ( select city_code from student where fname = "Linda" and lname = "Smith" ) and fname ! = "Linda" and lname ! = "Smith"
Of those three students, can you tell me which of them have more time spent in restaurants than Linda Smith?
select t1.stuid, sum ( t2.spent ) from student as t1 join visits_restaurant as t2 where city_code = ( select city_code from student where fname = "Linda" and lname = "Smith" ) and fname ! = "Linda" and lname ! = "Smith" group by t1.stuid having sum ( t2.spent ) > ( select sum ( spent ) from student as t1 join visits_restaurant as t2 on t1.stuid = t2.stuid where t1.fname = "Linda" and t1.lname = "Smith" )