logo

Back to questions

International Call Percentage [Verizon SQL Interview Question]

Medium

A phone call is considered an international call when the person calling is in a different country than the person receiving the call.

What percentage of phone calls are international? Round the result to 1 decimal.

Assumption:

  • The in table refers to both the caller and receiver.

Table:

Column NameType
caller_idinteger
receiver_idinteger
call_timetimestamp

Example Input:

caller_idreceiver_idcall_time
122022-07-04 10:13:49
152022-08-21 23:54:56
512022-05-13 17:24:06
562022-03-18 12:11:49

Table:

Column NameType
caller_idinteger
country_idinteger
networkinteger
phone_numberstring

Example Input:

caller_idcountry_idnetworkphone_number
1USVerizon+1-212-897-1964
2USVerizon+1-703-346-9529
3USVerizon+1-650-828-4774
4USVerizon+1-415-224-6663
5INVodafone+91 7503-907302
6INVodafone+91 2287-664895

Example Output:

international_calls_pct
50.0

Explanation

There is a total of 4 calls with 2 of them being international calls (from caller_id 1 => receiver_id 5, and caller_id 5 => receiver_id 1). Thus, 2/4 = 50.0%

The dataset you are querying against may have different input & output - this is just an example!

PostgreSQL 14