Need to find common and internal calls

Hi,
create table call(id number(15) primary key, calling_no varchar2(15), called_no varchar2(15), calldate date, calltime timestamp, duration number(10) ,
calltype varchar2(10));
1. CALL DETAILS OF 9891826547
insert into call (id,calling_no,called_no,calldate,calltime,duration,calltype) values (1, 9891826547, 9891210785, to_date('01-Jun-13','dd-Mon-yy'), to_date('19:12:00','hh24:mi:ss'),10,'OUT');
insert into call (id,calling_no,called_no,calldate,calltime,duration,calltype) values (2,9891826547, 9899985476, to_date('01-Jun-13','dd-Mon-yy'), to_date('22:10:12','hh24:mi:ss'),50,'OUT');
insert into call (id,calling_no,called_no,calldate,calltime,duration,calltype) values (3, 9891826547, 9818415767, to_date('02-Jun-13','dd-Mon-yy'), to_date('08:20:22','hh24:mi:ss'),170,'OUT');
insert into call (id,calling_no,called_no,calldate,calltime,duration,calltype) values (4, 9818415767,9891826547, to_date('02-Jun-13','dd-Mon-yy'), to_date('10:18:22','hh24:mi:ss'),220,'IN');
insert into call (id,calling_no,called_no,calldate,calltime,duration,calltype) values (5,9891826547,9899985476, to_date('02-Jun-13','dd-Mon-yy'), to_date('14:20:04','hh24:mi:ss'),220,'OUT');
2. CALL DETAILS OF 9818415767
insert into call (id,calling_no,called_no,calldate,calltime,duration,calltype) values (6,9818415767,9899985476, to_date('02-Jun-13','dd-Mon-yy'), to_date('06:13:20','hh24:mi:ss'),10,'OUT');
insert into call (id,calling_no,called_no,calldate,calltime,duration,calltype) values (7,9818415767,9891826547, to_date('02-Jun-13','dd-Mon-yy'), to_date('10:18:22','hh24:mi:ss'),220,'OUT');
insert into call (id,calling_no,called_no,calldate,calltime,duration,calltype) values (8,9899985476,9818415767, to_date('02-Jun-13','dd-Mon-yy'), to_date('12:05:08','hh24:mi:ss'),165,'IN');
REQUIRED OUTPUT :
1. INTERNAL CALLS:
CALLING_NO    CALLED_NO    CALLDATE         CALLTIME   DURATION   CALLTYPE
9818415767        9891826547     02-Jun-13             10:18:22            220                 IN
9848415767        9891826547     02-Jun-13             10:18:22            220                 OUT
2. COMMON NUMBER: 9899985476 [ BETWEEN 9818415767 AND 891826547 ]
CALLING_NO
CALLED_NO
CALLDATE    
CALLTIME   DURATION   CALLTYPE
9818415767       9899985476             02-Jun-13         06:13:20          10           OUT
9899985476       9818415767              02-Jun-13       12:05:08           165           IN
9891826547      9899985476              02-Jun-13        14:20:04           220          OUT
PLEASE HELP

Maybe NOT TESTED! No Database at hand just a guess
with
relevant_calls as
(select id,calling_no,called_no,calldate,calltime,duration,calltype
   from call
  where calling_no in (:number_1,:number_2)
     or called_no in (:number_1,:number_2)
select 'INTERNAL' kind_of,calling_no,called_no,calldate,calltime,duration,calltype
  from relevant_calls x,
       relevant_calls y
where (x.calling_no = y.called_no or y.calling_no = x.called_no)
   and x.calling_no != y.calling_no
   and x.called_no != y.called_no
union all
select 'COMMON' kind_of,calling_no,called_no,calldate,calltime,duration,calltype
  from relevant_calls
where called_no in (select called_no -- was called by both :number_1 and :number_2
                       from relevant_calls
                      where calling_no in (:number_1,:number_2)
                        and called_no not in (:number_1,:number_2)
                      group by called_no
                      having count(distinct calling_no) = 2
                     union all
                     select called_no -- was called by :number_1 and called :number_2
                       from relevant_calls x
                      where called_no not in (:number_1,:number_2)
                        and calling_no = :number_1
                        and exists(select null
                                     from relevant_calls
                                    where calling_no = x.called_no
                                      and called_no = :number_2
                     union all
                     select called_no -- was called by :number_2 and called :number_1
                       from relevant_calls x
                      where called_no not in (:number_1,:number_2)
                        and calling_no = :number_2
                        and exists(select null
                                     from relevant_calls
                                    where calling_no = x.called_no
                                      and called_no = :number_1
    or calling_no in (select calling_no -- called both :number_1 and :number_2
                        from relevant_calls
                       where called_no in (:number_1,:number_2)
                         and calling_no not in (:number_1,:number_2)
                       group by calling_no
                       having count(distinct called_no) = 2
Regards
Etbin

Similar Messages

  • Need to find common number

    Need to find common number among the set of calls :
    Create table call (id number(15) primary key not null , mobile_number number(10), other_party number(10), call_type varchar2(10),call_date_time date, duration number(15));
    insert into call values(1,9818764535,9899875643,'IN',to_date('24-APR-13 02:10:43','dd-MON-yy hh24:mi:ss'),10);
    insert into call values(2, 9897451236,9899875643,'OUT',to_date('28-APR-13 08:11:13','dd-MON-yy hh24:mi:ss'),20);
    insert into call values(3, 9899917277,9899875643,'IN',to_date('30-APR-13 18:07:02','dd-MON-yy hh24:mi:ss'),30);
    insert into call values(4,9818764535,9215478213,'IN',to_date('01-MAY-13 02:11:13','dd-MON-yy hh24:mi:ss'),40);
    insert into call values(5, 9899917277,9215478213,'IN',to_date('01-MAY-13 08:17:02','dd-MON-yy hh24:mi:ss'),25);
    insert into call values(6, 9897451236,9012451785,'OUT',to_date('01-MAY-13 20:21:04','dd-MON-yy hh24:mi:ss'),67);
    Query criteria :
    common caller for list of numbers who is in contact with listed numbers .
    Input Mobile_number:
    9818764535
    9897451236
    9899917277
    output common number
    Mobile number  otherparty date_time duration
    9818764535 9899875643 24-APR-13 02:10:43 10
    9897451236 9899875643 28-APR-13 08:11:13 20
    9899917277 9899875643 30-APR-13 18:07:02 30

    Thanks , it helped
    But if internal calls among these mobile numbers are to be find then
    insert into call values(1,9818764535,9899875643,'IN',to_date('24-APR-13 02:10:43','dd-MON-yy hh24:mi:ss'),10);
    insert into call values(2, 9897451236,9899875643,'OUT',to_date('28-APR-13 08:11:13','dd-MON-yy hh24:mi:ss'),20);
    insert into call values(3, 9899917277,9899875643,'IN',to_date('30-APR-13 18:07:02','dd-MON-yy hh24:mi:ss'),30);
    insert into call values(4,9818764535,9215478213,'IN',to_date('01-MAY-13 02:11:13','dd-MON-yy hh24:mi:ss'),40);
    insert into call values(5, 9899917277,9215478213,'IN',to_date('01-MAY-13 08:17:02','dd-MON-yy hh24:mi:ss'),25);
    insert into call values(6, 9897451236,9012451785,'OUT',to_date('01-MAY-13 20:21:04','dd-MON-yy hh24:mi:ss'),67);
    insert into call values(7,9818764535,9897451236,'IN',to_date('02-MAY-13 22:10:43','dd-MON-yy hh24:mi:ss'),100);
    insert into call values(8, 9899917277,9818764535,'IN',to_date('02-MAY-13 23:07:02','dd-MON-yy hh24:mi:ss'),130);
    Input Mobile_number:
    9818764535
    9897451236
    9899917277
    output internal calls :
    Mobile number otherparty call_type date_time duration
    9818764535 9897451236 IN 02-MAY-13 22:10:43 100
    9899917277 9818764535 IN 02-MAY-13 23:07:02 130

  • Ok, i have lost my ipod and i REALLY need to find it, and i have no idea how i can track it. HELP!!!!

    ok, i have lost my ipod and i REALLY need to find it, and i have no idea how i can track it. HELP!!!!

    There is no way to track a lost or stolen iPod Classic. Sorry.
    Reporting a lost or stolen Apple product
    B-rock

  • Query to find first and last call made by selected number for date range

    Hi,
    query to find first and last call made by selected number for date range
    according to filter:
    mobile_no : 989.....
    call_date_from : 25-april-2013
    call_date_to : 26-april-2013
    Please help

    Hi,
    It sounds like you want a Top-N Query , something like this:
    WITH    got_nums   AS
         SELECT     table_x.*     -- or list columns wanted
         ,     ROW_NUMBER () OVER (ORDER BY  call_date      ) AS a_num
         ,     ROW_NUMBER () OVER (ORDER BY  call_date  DESC) AS d_num
         FROM     table_x
         WHERE     mobile_no     = 989
         AND     call_date     >= DATE '2013-04-25'
         AND     call_date     <  DATE '2013-04-26' + 1
    SELECT  *     -- or list all columns except a_num and d_num
    FROM     got_nums
    WHERE     1     IN (a_num, d_num)
    ;This forum is devoted to the SQL*Plus and iSQL*Plus front ends. This question doesn't have anything to do with any front end, does it? In the future, you'll get better response if you post questions like this in the PL/SQL.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the SQL forum FAQ {message:id=9360002}

  • Need help finding Sound and Vibration Toolkit Example Files

    I need help finding some Sound and Vibration Toolkit Example Files?
    http://www.ni.com/white-paper/3779/en
    From this link you get:  getting_started_otb.llb
    The missing files are:
    OAT Truncate Time Indices.vi
    Speed profile.ctl
    oa_Config Time or RPM Segment.vi
    svl-Complex Datatype Default.vi
    Running Windows 7, LabVIEW 2011, 32bit
    Sound and Vibration Measurement Suite
    Sound and Vibration Toolkit
    Thanks,
    -SS
    Solved!
    Go to Solution.
    Attachments:
    License S and V.png ‏4 KB

    SS,
    You can find these files here:
    C:\Program Files (x86)\National Instruments\LabVIEW 2011\vi.lib\addons\Sound and Vibration\Order Analysis\Resample Order Tracking\SubVIs
    C:\Program Files (x86)\National Instruments\LabVIEW 2011\vi.lib\addons\Sound and Vibration\Order Analysis\Tach Process\SubVIs
    C:\Program Files (x86)\National Instruments\LabVIEW 2011\vi.lib\addons\Sound and Vibration\Order Analysis\Resample Order Tracking\SubVIs
    svl-Complex Datatype Default.vi changes to svc-Complex Datatype Default.vi
    C:\Program Files (x86)\National Instruments\LabVIEW 2011\vi.lib\addons\_NISVFA\_Shared subVIs\Common
    Make sure you are license activated, and you will have to dig through the *vi and relink a subvi.
    Then you should get a white arrow.
    -SS 

  • OWA for Iphone and international calling card

    Hello,
    I work as the Supervisor for a company that has just purchased many iphones.  The group that is in charge of email at my company will only allow "OWA for Iphone" to be used because in this way, nothing is downloaded to the device.  All email, calendar entries and contacts/people entries are web based.  Because nothing is downloaded to the device, the Iphone app for any international calling card company like Reliance or True Roots will not work.
    When I say, "will not work" this is why.  All international calling card companies apps that I have found, access the local downloaded contacts on the Iphone itself.  I have not found any that can connect to the people in the  "OWA for Iphone" app to make international calls for cheeper prices.
    Is there an international calling card company whose app will work with "OWA for Iphone" and not the locally stored contacts?  Or one that I can make the choice, choose the contacts from the local Iphone and or people in the "OWA for Iphone" app?

    International calling apps allow you to call an entry from your contact list.  When you make a call from your device using this International calling app it will hang up, dial a 1 800 or 1866 number, then redial the international number you dialed and complete the call.  This allows you to call for example, India for $.06/minute instead of $.50/minute or what ever your provider charges you.  It basically make it so your international calls go through your international calling app provider instead of your phone provider.  You still use your phone provider minutes, but the cost is rerouted to your international calling provider/partner.
    1. I know, its so hard to do anything.  Yes all smartphones (Iphones, Androids, Windows, etc...)  The email admins will not allow anything to directly download to the device from the company.  The OWA for IPhone app uses the web browser but changes the view of the email to look and feel user friendly.  Basically, OWA for Iphone is using the web to look at all email, contacts, and calendar entries.
    2. The international calling app (Reliance and all others I have found including Skype) will only look at local downloaded contacts.  Because we are using OWA for Iphone there are no downloaded contacts. So, the international calling app does not see the contacts to be able to call.
    If I go into OWA for IPhone and go to People and call somebody internationally +44 XX XXX XXXXX it works fine, but the international calling app does not activate becasue the app can't see the number.  This is because its looking only at the local downloaded contacts list, not the contacts on the web using OWA for Iphone

  • Need to find region and its sub region

    Hi,
    I have a table levels which has record at any levels.
    levels_id region_name region_parent
    1 xyz 0
    2 xyz1 1
    3 xyz2 2
    4 xyz3 3
    5 xyz11 1
    6 xyz12 5
    7 xyz21 1
    8 xyz22 7
    9 **** 100
    10 ***1 101
    i need to find all the region under levels_id = 1 at any levels
    Please help me
    regards
    shyam

    is this what you are after?
    with t as
    (select 1 levels_id,  'xyz' region_nm,  0 region_parent from dual union
    select 2, 'xyz1', 1 from dual union
    select 3,'xyz2', 2 from dual union
    select 4, 'xyz3', 3 from dual union
    select 5, 'xyz11', 1 from dual union
    select 6, 'xyz12', 5 from dual union
    select 7, 'xyz21', 1 from dual union
    select 8, 'xyz22', 7 from dual
    select /*levels_id, region_nm, region_parent,  */
    substr(sys_connect_by_path(region_nm, '-->'),4)  from t
    where connect_by_isleaf = 1
    --start with  region_parent = 1
    connect by prior region_parent = levels_id
    xyz
    xyz1-->xyz
    xyz2-->xyz1-->xyz
    xyz3-->xyz2-->xyz1-->xyz
    xyz11-->xyz
    xyz12-->xyz11-->xyz
    xyz21-->xyz
    xyz22-->xyz21-->xyz

  • Sql query to find answered and received calls for month or day

    Hi  experts !
    1.Any one help in finding out the received, answered and missed ,transfered  in  /  out  calls  in  UCCE  using SQL query for a particular month or day.
    2. We have some  custom report templetes defined ,  need to  know  , how can we  write Sql  query  to  get those  values  from  custum reports.
    due to some issues,  cannot use  webview .

    Hi,
    there's no such thing as reporting "for a particular Team". Teams in ICM are for administration purposes only (to have grouping of agents). ICM does not count the number of calls received by "teams". If there is a report in Webview "by team", it's always by agent. Try to run the report against a team once and then try to remove certain agents from that team - you'll see the difference.
    What you are looking for is either reporting by Agent or by Agent/Skill group combination.
    Try to explore the
    - Agent_Half_Hour
    - Agent_Skill_Group_Half_Hour
    - Skill_Group_Half_Hour
    database views.
    The database schema documents are here:
    http://www.cisco.com/en/US/products/sw/custcosw/ps1844/prod_technical_reference_list.html
    Good luck.
    G.

  • X300 - Need help finding the correct internal DVD Burner

    I want to buy and install an internal DVD burner, which I am unable to identify on the Lenovo website.  The only internal Ultrathin DVD burners I find fit the x200 series, but nothing for the x300 series.  Frustrating.
    Mine is a Thinkpad x300, Type 6477, and S/N L3-xxxxx.
    Anyone able to help me identify the correct part number?
    Thanks!
    Moderator Note; s/n edited for members own protection

    . . . thanks for the part IDs, lead_org. . . . took your advice and searched ebay for both, but nothing surfaced. . . . so, I entered the parts numbers into Lenovo's Websales site and was unable to find any such part listings for sale anywhere . . . nothing. . . . then, I emailed Lenovo Websales about it . . . they promptly replied that the parts were not in stock, and that I could try purchasing from www.cdw.com . . . I can understand if Lenovo did not have them in stock, but that they would not even LIST the parts was weird. . . . this is a 1-1/2 year old machine . . . are the lifecycles for laptops these days so short that they are unsupported even this fast? . . . I did see a few other sites selling the replacement DVD as new (presumably) for US$300, but none were in stock. . . . if I have no other alternatives, is a DVD the sort of part that is durable enough to reliably purchase used? Thanks!

  • Need to find Holidays and Day

    Hello All,
    I have the PLANT and DATE.
    With these details how can I find
    1. DATE is a holiday?
    2. DATE is which day(Mon, Tue,..., Sun)?
    Good answers will be appreciated.
    Thanks in advance.
    Best Regards,
    Sasidhar Reddy Matli.

    Try function module [DATE_CONVERT_TO_FACTORYDATE|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=date_convert_to_factorydate&adv=false&sortby=cm_rnd_rankvalue] or [HOLIDAY_CHECK_AND_GET_INFO|https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=holiday_check_and_get_info&adv=false&sortby=cm_rnd_rankvalue] the factory calendar comes from table T001W.
    Regards

  • U160: Need help finding one and your opinion. Hardware update coming soon?

    I really want to pick up an Ideapad u160 after playing around with a x120e for the last week. But, in the US it is nearly impossible to find one.
    Lenovo does offer the Core i3 version for $750 (a bit over priced in my opinion) from the website, but only in brown. I would love to get a black on with an i5 or i7.
    The only place I could find them was on eBay and that was a refurbished one: http://cgi.ebay.com/LENOVO-Ideapad-U160-12-500GB-4GB-BT-i7-640UM-Ultrathin-/270778848252?pt=Laptops_...
    How are Lenovo's refurbished laptops? And I am guessing the u160 would be a huge bump in performance from the x120e.
    Finally, there has been no talk of a refresh for the u160 line right? I would hate to buy one and then be left with the old modle.
    Thanks!

    You don't want to reset all settings .... You have to totally restore the iPad to factory settings which erases the device. After you restore the iPad, you can sync your content back onto the iPad from your iTunes library.
    Read this to see what I am talking about. This article talks about the iPhone, but it works the same way with an iPad or an iPod Touch.
    http://www.maclife.com/article/howtos/how_recover_your_restrictions_password
    Do you sync with iTunes on a regular basis? If yo don't, you can download past purchases as long as you use the same Apple ID that you originally bought the content with and as long as the content is still available in the stores (iTunes, the App Store or the iBooks Store).
    When you restore the iPad to factory settings, your son's game progress will be lost as well, so keep that in mind. All app data and settings will be erased when you restore as a new device.
    This discussion has some helpful tips on how to save some of the iPad content before you restore as new.
    https://discussions.apple.com/thread/3695870?tstart=0
    Message was edited by: Demo

  • My phone is locked and doesnt recognize me as a Developer.  Need to find UDID and cannot use Itunes or the phone, any ideas?

    I have a new phone, through AT&T insurance, and it does not recognize me as a developer until i register UDID.  But the phone is locked and has never synced to Itunes so how the **** do I find the UDID number?  This one is stumping me?

    Ok next problem currently my MAC is with my daughter out of state, I only have a PC in the house...

  • I have lost my ipod and it has phtos of my late grandfther and im really sad i need to find it and i cant any advice

    NY ADVICE PLEASE

    - If they are in an iPod backup then restore another iPod touch, iPad or iPhone from from that backup. After y are done, just have them restore the device from their backup See the restore topic of:
    iOS: How to back up
    - If you used PhotoStream then try getting them from your PhotoStream. See that topic of:
    iOS: Importing personal photos and videos from iOS devices to your computer

  • I lost my ipod and i didnt turn on the find my iphone so how do i find it and i really need it :(

    i lost my ipod touch and i need to find it and the find my iphone is not on plz help

    - If you previously turned on FIndMyiPod on the iPod in Settings>iCloud and wifi is on and connected go to iCloud: Find My iPhone, sign in and go to FIndMyiPhone. If the iPod has been restored it will never show up.
    - You can also wipe/erase the iPod and have the iPod play a sound via iCloud.
    - If not shown, then you will have to use the old fashioned way, like if you lost a wallet or purse.
    - Change the passwords for all accounts used on the iPod and report to police
    - There is no way to prevent someone from restoring the iPod (it erases it) using it.
    - Apple will do nothing without a court order                                                        
    Reporting a lost or stolen Apple product                                               
    - iOS: How to find the serial number, IMEI, MEID, CDN, and ICCID number

  • I need to find and upload a hidden file for an app service issue

    I need to locate a hidden file, filename.plist which is on a networked drive, and upload it to the company;s wed=biste for the to support the app. Obviously 'filename' is just a word. there is a long and complex filename.
    Finder spins its wheels uselessly when I ask it to search. The action gear thingy has no useful options to see hidden files that I can see. And the upload part of the website, while it lets me enter the filename in the search box, just spins uselessly, too.
    The file is held on a networked freestanding drive. That isn't of itself, any real problem. I just need to find it and upload it so I can get support. I don;t mind using some utility to grab a copy of it somehow, and uploading that! BUT I am not hugely technical, so I need to be spoon fed.

    You can use Terminal to find the file you are looking for.
    Let's say your network drive is named Net_Drive
    find /Volumes/Net_Drive -name filename.plist
    if you know the exact file name or
    find /Volumes/Net_Drive -name *.plist
    to search for all file names ending with .plist

Maybe you are looking for

  • How do I change my default back to Safari from Firefox?

    I installed Firefox on my Macbook. Somehow, as part of the install, it became the default browser for links from Mail. I'd rather use Safari as my default app. Is there a place to change default browsers, and more broadly, is there a place to assign

  • Unwanted bookmarks when generating a PDF in FM 8.0

    I have a issue about generating bookmarks when creating a PDF. After I have finished my book, I identify my bookmarks while in the PDF setup window. But for some reason, FM creates bookmarks for paragraph tags that I didn't choose. This is happening

  • Lost messages when pulling from MQ via bridge

    Hi all,           I'm using a bridge to pull messages from MQ, sort them, and republish them into one of several outbound topics. I've received word from a consumer application that they aren't seeing all the messages they expect. Sure enough, they'r

  • Creating Query similar to excel command

    Hi Experts I have a query which outputs dataset from OITM table and includes 5 UDFs I have called TID1, TID2, TID3, TID4 and TID5. Once the query is run I then have to take it into Excel and run formula which returns the value for the last non-blank

  • Credit management related issue - please respond ASAP

    Hi, I have a credit management related issue, The requirement is as below:- If receivables value is zero for a customer and after a sales order is saved and delivery is created, a check should happen to see if the GROSS (Total including VAT) , not Ne