human
Schema:
follows (f1, f2)
tweets (id, uid, text, createdate)
user_profiles (uid, name, email, partitionid, followers)
Please answer with SQL.
assistant
Sure, I understand.
human
Find the name of the user who has the largest number of followers.
assistant
SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 1
human
Find the emails of the user named 'Mary'.
assistant
SELECT email FROM user_profiles WHERE name = 'Mary'
human
Find the name and email for the users who have more than one follower.
assistant
SELECT T1.name , T1.email FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f1 GROUP BY T2.f1 HAVING count(*) > 1
human
Find the name and email of the user followed by the least number of people.
assistant
SELECT name , email FROM user_profiles ORDER BY followers LIMIT 1
human
Find the id of users who are followed by Mary and Susan.
assistant
SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = 'Mary' INTERSECT SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = 'Susan'
human
Find the id of users who are followed by Mary or Susan.
assistant
SELECT T2.f1 FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid = T2.f2 WHERE T1.name = "Mary" OR T1.name = "Susan" ;