![]() |
Finding Count of Outgoing and Incoming calls from a Caller Log table in Oracle
In day to day life we all use mobile phones and make outgoing and incoming calls. Normally our each call will be stored in the caller log in telecommunication tables.
We will call to call center to enquire about the no. of incoming calls and outgoing calls we have done. They will enter our no. in the portal and backend it will query it caller log table and it will provide the results. Now we will see how it works by looking into below scenario. Let us suppose we have a caller_log table and data as below Code:
CALLERID CALLER CALLEDTOIf we observe the caller_log table we will find that no. of outgoing from mobile no. 123 is 3 (two times called to 456 and one time to 678) and no. of incoming is 1 (456 called one time to 123). We need output as below Code:
CALLER OUTGOING INCOMINGBelow query will give the required output Code:
select A.caller,A.outgoing,B.incoming from Code:
select caller ,count(*) outgoing from pbatch.caller group by callerCode:
CALLER OUTGOINGCode:
select calledto,count(*) incoming from pbatch.caller group by calledtoCode:
CALLEDTO INCOMINGWe will treat these two inner queries as two table and join based on caller and calledto which will give the required output. If we add one more date column then we can roll-up the date based on date. If we add two more columns incoming time in sec and outgoing time in sec then we will have complete table of caller_log. Now we can write query for total no. of incoming and outgoing calls with total no. of outgoing sec and incoming sec on a particular date. We can use below query to achieve above output by using connect by prior clause Code:
select A.caller,A.outgoing,B.incoming from |
| All times are GMT +5.5. The time now is 11:14. |