logo

Back to questions

NYC Area Code [Verizon SQL Interview Question]

Medium

The first 3 digits of American phone numbers, after the international code (of +1) are called the area code.

How many phone calls have either a caller or receiver with a phone number with a Manhattan NYC area code (ie. +1-212-XXX-XXXX).

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:

nyc_count
3

Explanation

Caller ID 1 is the only NYC phone number (see the 212 after the +1). Caller 1 is involved in 3 calls.

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

PostgreSQL 14