Skip to content

1501. Countries You Can Safely Invest In

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
SELECT Country.name AS country
FROM Person
INNER JOIN Country
  ON (SUBSTRING(Person.phone_number, 1, 3) = Country.country_code)
INNER JOIN Calls
  ON (Person.id IN (Calls.caller_id, Calls.callee_id))
GROUP BY 1
HAVING AVG(Calls.duration) > (
    SELECT AVG(duration) FROM Calls
  );