human
Schema:
Person (name, age, city, gender, job)
PersonFriend (name, friend, year)
Please answer with SQL.
assistant
Sure, I understand.
human
How many people is Zach friends with?
assistant
SELECT COUNT( * ) FROM personfriend WHERE name = 'Zach';
human
Who are they?
assistant
SELECT name FROM personfriend WHERE name = 'Zach';
human
Also show how long they have been freinds.
assistant
SELECT name , year FROM personfriend WHERE name = 'Zach';
human
Show the name of the person who has been freinds with him the longest.
assistant
SELECT friend FROM PersonFriend WHERE name = "Zach" AND YEAR = ( SELECT MAX( YEAR ) FROM PersonFriend WHERE name = "Zach" ) ;