Database: twitter_1

Question: Find the name and email of the user whose name contains the word ‘Swift’.
SQL: SELECT name ,  email FROM user_profiles WHERE name LIKE '%Swift%'

Question: Find the names of users whose emails contain ‘superstar’ or ‘edu’.
SQL: SELECT name FROM user_profiles WHERE email LIKE '%superstar%' OR email LIKE '%edu%'

Question: Return the text of tweets about the topic 'intern'.
SQL: SELECT text FROM tweets WHERE text LIKE '%intern%'

Question: Find the names of the users whose number of followers is greater than that of the user named "Tyler Swift".
SQL: SELECT T1.name FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 GROUP BY T2.f1 HAVING count(*)  >  (SELECT count(*) FROM user_profiles AS T1 JOIN follows AS T2 ON T1.uid  =  T2.f1 WHERE T1.name  =  'Tyler Swift')

Question: Find the name and email for the users who have more than one follower.
SQL: 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

Question: Find the names of users who have more than one tweet.
SQL: SELECT T1.name FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  >  1

Question: Find the id of users who are followed by Mary or Susan.
SQL: 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"

Question: Find the name and email of the user followed by the least number of people.
SQL: SELECT name ,  email FROM user_profiles ORDER BY followers LIMIT 1

Question: List the names of 5 users followed by the largest number of other users.
SQL: SELECT name FROM user_profiles ORDER BY followers DESC LIMIT 5

Question: Find the name of each user and number of tweets tweeted by each of them.
SQL: SELECT T1.name ,  count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid

Question: Find the name and partition id for users who tweeted less than twice.
SQL: SELECT T1.name ,  T1.partitionid FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  <  2

Question: Find the name of the user who tweeted more than once, and number of tweets tweeted by them.
SQL: SELECT T1.name ,  count(*) FROM user_profiles AS T1 JOIN tweets AS T2 ON T1.uid  =  T2.uid GROUP BY T2.uid HAVING count(*)  >  1

Question: Find the average number of followers for the users who had some tweets.
SQL: SELECT avg(followers) FROM user_profiles WHERE UID IN (SELECT UID FROM tweets)