Person
table with the Country
table on the country code extracted from the phone_number
column.Calls
table where the Person.id
matches either Calls.caller_id
or Calls.callee_id
.GROUP BY
clause to group the results by country name.AVG
function.Calls
table.HAVING
clause to filter the results where the country's average call duration is greater than the global average.erDiagram Person { int id varchar name varchar phone_number } Country { varchar name varchar country_code } Calls { int caller_id int callee_id int duration } Person ||--o{ Calls : "" Country ||--o{ Person : ""