Loading problem...
A commerce platform stores customer identity records, customer-maintained contact lists, and invoice transactions in three relational tables.
Table: customers
Table: contacts
Table: invoices
Task: For every invoice, compute a contact trust coverage summary.
For each invoice row, return:
Output requirements:
Supported submission environments:
customers:
| customer_id | customer_name | email |
|-------------|---------------|---------------------|
| 1 | Alice | alice@shop.com |
| 2 | Bob | bob@shop.com |
| 13 | Joon | joon@shop.com |
| 6 | Alex | alex@shop.com |
contacts:
| user_id | contact_name | contact_email |
|---------|--------------|--------------------|
| 1 | Bob | bob@shop.com |
| 1 | Joon | joon@shop.com |
| 1 | Maya | maya@extmail.com |
| 2 | Omar | omar@extmail.com |
| 2 | Meir | meir@extmail.com |
| 6 | Alice | alice@shop.com |
invoices:
| invoice_id | price | user_id |
|------------|-------|---------|
| 77 | 100 | 1 |
| 88 | 200 | 1 |
| 99 | 300 | 2 |
| 66 | 400 | 2 |
| 55 | 500 | 13 |
| 44 | 60 | 6 |[
{"invoice_id":44,"customer_name":"Alex","price":60,"contacts_cnt":1,"trusted_contacts_cnt":1},
{"invoice_id":55,"customer_name":"Joon","price":500,"contacts_cnt":0,"trusted_contacts_cnt":0},
{"invoice_id":66,"customer_name":"Bob","price":400,"contacts_cnt":2,"trusted_contacts_cnt":0},
{"invoice_id":77,"customer_name":"Alice","price":100,"contacts_cnt":3,"trusted_contacts_cnt":2},
{"invoice_id":88,"customer_name":"Alice","price":200,"contacts_cnt":3,"trusted_contacts_cnt":2},
{"invoice_id":99,"customer_name":"Bob","price":300,"contacts_cnt":2,"trusted_contacts_cnt":0}
]Alice has 3 contacts and 2 trusted contacts. Bob has 2 contacts and none are trusted. Alex has 1 trusted contact. Joon has no contacts.
customers:
| customer_id | customer_name | email |
|-------------|---------------|------------------|
| 10 | Nora | nora@corp.io |
| 11 | Luis | luis@corp.io |
contacts:
| user_id | contact_name | contact_email |
|---------|--------------|--------------------|
| 10 | Vendor A | billing@vendor.io |
invoices:
| invoice_id | price | user_id |
|------------|-------|---------|
| 1 | 80 | 10 |
| 2 | 120 | 11 |[
{"invoice_id":1,"customer_name":"Nora","price":80,"contacts_cnt":1,"trusted_contacts_cnt":0},
{"invoice_id":2,"customer_name":"Luis","price":120,"contacts_cnt":0,"trusted_contacts_cnt":0}
]Customer 10 has one untrusted contact. Customer 11 has no contacts.
customers:
| customer_id | customer_name | email |
|-------------|---------------|------------------|
| 1 | Priya | priya@data.ai |
| 2 | Raj | raj@data.ai |
| 3 | Mina | mina@data.ai |
contacts:
| user_id | contact_name | contact_email |
|---------|--------------|-----------------|
| 1 | Raj | raj@data.ai |
| 1 | Raj Caps | RAJ@data.ai |
| 1 | Mina | mina@data.ai |
invoices:
| invoice_id | price | user_id |
|------------|-------|---------|
| 7 | 900 | 1 |
| 8 | 300 | 1 |[
{"invoice_id":7,"customer_name":"Priya","price":900,"contacts_cnt":3,"trusted_contacts_cnt":2},
{"invoice_id":8,"customer_name":"Priya","price":300,"contacts_cnt":3,"trusted_contacts_cnt":2}
]Email matching is exact in this setup, so RAJ@data.ai does not match raj@data.ai.
Constraints