Skip to content
Advertisement

Finding who called who

I have these two tables. Subscriber table contains SubscriberID and his Phone number. NetworkP2P contents SubscriberID, to who he has called AddresseeNumber and when the call started, ended.

Example data:

Subscriber

NetworkP2P

Not all Phone numbers match the ones that Subscribers have.

How would I approach this, if I wish to have which outputs subscribers who have been in contact with each other for a given month, i.e. subscriber1 called subscriber2 and vice versa?

Example of the desired output:

Advertisement

Answer

Your model is not wrong as suggested in comments – your NetworkP2P might be missing only one column (Reciever), which could work as optional foreign key (to satisfy your sentence “Not all Phone numbers match the ones that Subscribers have.”), but it looks more log than relational table.

Query for your desired output:

You should always use database schema for all your tables (for example dbo.Subscriber).

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement