Retrieve only one type of phone number

Hi
In the following sample query I need to retrieve only one phone number. The preference is if Mobile available - mobile number if not Home number (Type - H1), else Work number (W1).
I have included the script and sample output what I am getting from the SQL
Thanks in advance
Regards
Sriram
select pp.ph_id
,papf.person_id
,pp.ph_type
,pp.ph_no
,pp.date_from
,pp.date_to
from per_phones                      pp
,per_all_people_f                    papf
,per_contact_relationships           pcr
where papf.person_id = pp.parent_id
and pcr.person_id = papf.person_id
and trunc(sysdate) between trunc(nvl(pcr.date_start, sysdate-1))
and trunc(nvl(pcr.date_end, sysdate+1))
and papf.person_id in (146564, 514)
and pcr.primary_contact_flag  = 'Y'
and trunc(sysdate) between papf.effective_start_date and papf.effective_end_date
and trunc(sysdate) between nvl(pp.date_from, sysdate-1) and nvl(pp.date_to, sysdate+1);output
PH_ID     PERSON_ID     PH_TYPE     PH_NO     DATE_FROM     DATE_TO
3261     514          H1          987524879     13-Jun-04     
117287     514          M          0403672797     11-May-05     
141997     146564          H1          54789620     15-Feb-06     05-Mar-10
311028     146564          H2          235469          5-Dec-09     
311029     146564          W1          8300054          15-Dec-09     
311108     146564          M          04126872     12-Feb-10

Not tested, but something like this might do the trick. What you need to do is assign a hierarchy to the phone type codes, then choose the top one for each parent id.
WITH phone_list
  AS ( SELECT parent_id,
              MIN( CASE ph_type
                     WHEN 'M'  THEN 1
                     WHEN 'H1' THEN 2
                     WHEN 'W'  THEN 3
                     ELSE 99
                   END )  AS phone_pref
         FROM per_phones
        GROUP
           BY parent_id )
SELECT pp.ph_id,
       papf.person_id,
       pp.ph_type,
       pp.ph_no,
       pp.date_from,
       pp.date_to
  FROM per_phones                pp,
       per_all_people_f          papf,
       per_contact_relationships pcr,
       phone_list                lst
  WHERE papf.person_id = pp.parent_id
    AND pcr.person_id = papf.person_id
    AND trunc(sysdate) between trunc(nvl(pcr.date_start, sysdate-1))
    AND trunc(nvl(pcr.date_end, sysdate+1))
    AND papf.person_id in (146564, 514)
    AND CASE pp.ph_type
                     WHEN 'M'  THEN 1
                     WHEN 'H1' THEN 2
                     WHEN 'W'  THEN 3
                     ELSE 99
                   END = lst.phone_pref
   AND pp.parent_id = lst.parent_id;

Similar Messages

  • Two-step verification needs one SMS capable phone number. As I am a Bangladeshi how can I send phone number.pl help.

    Two-step verification needs one SMS capable phone number. Bangladesh is not listed country. How can I receive message my phone.

    2-step verification is not available in Bangladesh as yet.

  • We have 2 iphones both synched to 1 ipad how do we reovw phone numbers from only one of the phones

    We have 2 iphones and they are both synched to an ipad, how do we reomve phone numbers from only one of the phones without hte numbers being removed from the other phone

    one can't sync iPhones with ipads
    best you can do is to sync all with iclouds
    if you do so and wish to stop syncing contacts with one of the iPhones you have set it not to sync contacts in the settings of the iPhone

  • Two Iphones on the same WiFi network, using the same Apple ID receive calls meant for only one of the phones.

    My husband and I each have an IPhone 6.  We are using the same WiFi network and the same Apple ID, the phone numbers are different.  When we are at home, both phone receive calls meant for one of the phones.  Call can be answered from either phone.  Is this a new feature and How can I turn it off?

    go into settings then FaceTime then turn off iPhone cellular calls

  • My iMessages are only showing email not phone number

    Can anyone please advise?

    Hello PrestonGirl,
    I found this article while researching what you are describing here, named iOS 6 and OS X Mountain Lion: Link your phone number and Apple ID for use with FaceTime and iMessage found http://support.apple.com/kb/HT5538
    Phone number missing on iPad or iPod touch
    If your phone number is not listed on an iPod touch or iPad, follow these steps:
    Update to the latest version of iOS.
    Verify that you're using the same Apple ID that you are using on your iPhone.
    On your iPad or iPod touch, sign out of your Apple ID in the following locations:
    Settings > Messages > Send & Receive. Tap your Apple ID, then tap Sign Out.
    Settings > FaceTime. Tap your Apple ID, then tap Sign Out.
    Sign in to your Apple ID with FaceTime and iMessage.
    If your phone number is still not listed, follow these steps:
    Sign out of your Apple ID on all iOS devices, including your iPhone, in the following locations:
    Settings > Messages > Send & Receive. Tap your Apple ID, then tap Sign Out.
    Settings > FaceTime. Tap your Apple ID, then tap Sign Out.
    Sign in to your Apple ID on your iPhone.
    When activation is complete, your Apple ID and all verified email addresses should be visible in Settings > Messages > Receive At and also in Settings > FaceTime.
    Now sign in to your Apple ID on your other iOS devices.
    Take care,
    Sterling

  • How do you get iMessages sent to your e-mail address only and not your phone number?

    I want to send messages using my texts as well as iMessages to my girlfriend, she has a iPhone 3GS (I have iPhone 4) but i can't receive her texts when my internet is off, and only get her iMessages when I have turned my internet on. Is there something both of us have done or one of us?

    Sorry about the confusion. What I actually meant was:
    In Firefox you could use a method supported by the particular site like drag-and-drop from the desktop/folder into the webpage, use a button on the page to open/browse/upload an image/file etc.
    But this error (send error) "1file can't be sent" seems to be related to the email site's service. The email site's support/forum could be helpful. You could also try to inform them about the error if they provide a contact channel.
    You could also check the email site's help pages for information related to attachment size limits, and image type restrictions.

  • Select only one type of field using JavaScript in Acrobat X

    Looking for a way to select all fields of the same type on a form at once?
    Such as selecting all text fields to modify the font type, or all buttons to modify display values. Prior versions 6,7, & 8 were able to do this. Would prefer a script for each control type however I do not see any information in the JavaScript Reference Guide about this.

    The is no UI for selecting field by type in the newer versions of Acrobat.
    Have you looked at the numFields property and example?
    With some modification:
    function FindFieldType(cType)
    var aFieldNames = new Array(); // array of fields of type sFieldType
    // walk the array of field names;
    for ( var i = 0; i < this.numFields; i++) {
      var fname = this.getNthFieldName(i); 
      if ( fname.type = cType ) {
      // match to field type - add to array of names;
      aFieldNames[aFieldNames.length] = fname;
      } // end walk array of field names
    return aFieldNames;
    } // end FindFieldType function
    var aMyFields = new Array();
    // find button field type
    aMyFields = FindFieldType("button");
    // now do something with the array of field names;
    app.alert("button fields: \n" +  aMyFields.join("\n");

  • Retrieving only one row where the date is the greatest.

    Hello;
    I have a table of received orders, sometimes each order has multiple receipts due to back-orders and thus several rows for each purchase order receipt. All of the values in the table are identical except for the ReceivedDate field.
    I need to only get the row that has the latest ReceivedDate so I can ascertain whether the shipment has been received on-time or if it is late. For example, if I have a promised date from my vendor of 2015-01-31 for 50 widgets. I receive 40 widgets on 2015-01-29
    another 5 on 2015-01-31 and the last 5 on 2015-02-01, the entire shipment is considered to be late because I got my last widgets past the promised date.
    In my report, I don't care about the quantity received, I only care about when they were received Vs the promised date.
    So how can I only get the row that has the latest date (2015-02-01 in my example) so that I can do my on-time comparison?
    Appreciate any and all help.
    Thanks Ron...

    Hi, assuming to work in AdentureWorks db you can execute this script
    use AdventureWorks2012
    go
    select
    CustomerId,
    orderdate,
    max(orderdate) over (partition by CustomerId) as maxOrderDateForCustomer
    from sales.SalesOrderHeader
    to search all the order for each CustomerId and compare the date of each order with tha max date of all customer's orders.
    Hope this will help you
    Best regards
    Questo post è fornito "così com'è". Non conferisce garanzie o diritti di alcun tipo. Ricorda di usare la funzione "segna come risposta" per i post che ti hanno aiutato a risolvere il problema e "deseleziona come risposta" quando
    le risposte segnate non sono effettivamente utili. Questo è particolarmente utile per altri utenti che leggono il thread, alla ricerca di soluzioni a problemi similari. ENG: This posting is provided "AS IS" with no warranties, and confers no rights.
    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • DMS Connector for KM : I see only one document type from the document area

    Hi,
    The DMS connector is installed successfully on KM.
    I can display folder tree and documents but I see only one type of document.
    I mean, when I use transaction OAC0, I see different content repository defined in DMS.
    I wonder where is the setting that specified which content is link to the DMS connector for KM.
    Thanks in advance.

    Hello Zbynek,
    I installed the DMS once, but my experience how to use it is poor.
    In the Backend ( Transaction CV01N i think,) you can store search variants using the prefix you have defined for the DMSRM (default is KM_<theName>). This variants can be used to filter out several documents. There must be a way to give authorizations on them. Maybe you will have to use a security manager, i don't know.. in our case the user persistence (authScheme) was SAP-System an no TREX involved.
    It is not much, but maybe it helps...
    best regards
    Guido

  • HT204380 I am not able to make a FaceTime call to an Apple ID with iOS 7?  The only option is for a phone number

    When I go in to the contact, the facetime icon is only located below the phone number.  I am not given the option to FaceTime with an Apple ID.  Is there a setting or something that I need to go in and change in order to make FaceTime calls to an Apple ID??
    Any assistance would be greatly appreciated.

    They have to have facetime on there device as well and enabled with phone number and or apple id.
    THERE apple id needs to be in your contacts and YOUR apple id needs to be in there contacts

  • TS2755 All of a sudden only the phone number of my contact appears in messages and not the name. How do I get it back to displaying names?

    I'm only seeing my contacts phone number instead if their name when I get a message. How do I get it to show their name?

    I did that but nothing has changed. I only have a few contacts. Messages just showing numbers. If I start a message with a name it pulls it from somewhere but then changes to the their number

  • Save a phone number without the input mask

    Hi,
    I actually have 2 related issues that I hope you might be able to help me with.
    I have a form linked to an interactive report, so when I click a record, the form is populated with the record's data. I just started using the new text field masked input plugin to handle phone number formatting, etc., which Patrick recommended.
    The plugin works nicely when a phone number being displayed from the source is 10 characters. The input mask I'm using is (999) 999-9999. However, I also have phone numbers in records that don't include the area code. When I select one of those records, the phone number field is blank. I would like it to display 999-9999, and be right justified. Is there an easy fix for that?
    My next problem occurs when I try to save the record. The process tries to save the phone number, including the mask, (14 characters), to the table. I only want to save the number to the table, excluding the mask. I'm sure there is a way to do this but I haven't found it yet.
    Thanks in advance for any help,
    Gary

    This is my solution to parsing the number only from the masked phone number:
    1) Create a field, 'P1_PHONE_MASKED', with a phone number mask: (?***) 999-9999
    2) Create a hidden Database Column like: 'P1_PHONE' It will initially hold the value of the record's phone column.
    3) create a javascript function in the page's before header section, between the space tags, to strip out all non-numeric values and update the hidden field:
    function remmask(src,tar){
    var mystring = $x(src).value;
    mystring = mystring.replace(/\D/g,'');
    $x(tar).value = mystring;
    4) Place the function call in the from in the HTML Form Elements Attributes of P1_PHONE_MASKED: onBlur="javascript:remmask('P1_PHONE_MASKED','P1_PHONE');"
    Now, anytime you change the value in P1_PHONE_MASKED, P1_PHONE gets updated with just the number values from P1_PHONE_MASKED.
    You can also add validation to the function to ensure that the length of the phone number is either 7, no area code, or 10, including area code. Normally, the mask should handle validation, but as you can see, to make this work, I had to make the mask more flexible, to allow for alpha numeric values in the first 3 positions and to allow for either 7 or 10 characters. Unfortunately, that means a user could enter something like XXX12 and the mask won't reject it.
    Partial solution to displaying ( ) 999-9999 in the masked input field P1_PHONE_MASKED when initially selecting a record for display.
    1) Make the Source Type for P1_PHONE_MASKED "SQL Query"
    2) Insert a query similar to the one below into "Source Value or Expression"
    SELECT
    CASE
    WHEN length(METAREPO.CONTACTS.CONTACT_PHONE) = 10
    THEN
    METAREPO.CONTACTS.CONTACT_PHONE
    WHEN length(METAREPO.CONTACTS.CONTACT_PHONE) = 7
    THEN
    '___'||METAREPO.CONTACTS_2011.CONTACT_PHONE
    END
    FROM METAREPO.CONTACTS
    WHERE METAREPO.CONTACTS.CONTACT_ID = :P1_CONTACT_ID
    This will display 7 digit phone nubers as follows: (___) 999-9999 in the masked field: P1_PHONE_MASKED.
    I wanted to use spaces between the () to make it perfect, but I'm unable to get this to work. I've tried things like:
    ' '||METAREPO.CONTACTS_2011.CONTACT_PHONE
    LPAD(METAREPO.CONTACTS_2011.CONTACT_PHONE,3,' ')
    Both of which work in PL/SQL Developer, but not in Apex. I believe this is because HTML collapses spaces by default.
    I would like very much to resolve this last issue. Any suggestions?
    Regards,
    Gary

  • Problem with iMessage contacts being separated by phone number and email

    Hi all, sorry if this thread is a duplicate of another, I've seen some that are similar but none seem to match the exact situation I'm having.
    Me and 3 other friends have a group iMessages thread where we talk to each other.
    We each have several devices: ie. I have a Macbook Air and an iPhone 5S, one has a Macbook, an iPhone 4, and an iPad, etc etc. Essentially we all have a mix of devices which we can use to read the thread, all using the same Apple ID and with our phone number added.
    The problem is, every so often and for no discernible reason, someone will send a message and it'll start a new thread: this usually happens on my iPhone but occasionally it happens on my Macbook. Sometimes, what has become 2 threads on my phone will be only one thread on my Macbook, and vice versa. Same applies to my friends. However, sometimes what has become 2 threads for them is still only one thread for someone else, as though some of us have gone "out of sync".
    When you compare the contacts in the 2 threads, they are IDENTICAL (can't stress this enough, the contacts themselves have not been duplicated), however when I look at the same contact from one thread, their phone number will be highlighted in blue. In the other thread, their email address will be highlighted in blue.
    Therefore the problem seems to be that devices are unable to bring together an iMessage sent from a contact's phone with one sent from their email. If the information for both email and phone number are correctly filled in for a contact, why can Messages/iMessage not realise it is the same person and bring them together?
    The problem is, sometimes a message sent from the same device will first be sent from the phone number, then the next will be from the email address (or rather, everyone else's devices are seeing it that way, they're not doing anything different than usual, just typing in the thread and pressing send). Its as though the device is choosing one then the other, seemingly at random, and iMessage doesn't seem to be able to add them to the already existing thread but instead creates a new one as the "source' is different. Is this behaviour intended? Surely it can't be.
    Is this something to do with the "You can be reached by iMessage at" setting in iOS. One of us needs to be reached by both his email and phone number so we can't just all turn off the email on our phones/iPads for example.
    Is this a known problem? Is there something we can do about it? Is it ever going to be fixed?
    We've tried other messaging programs but they're just not as well integrated as Messages, and obviously being able to switch between my phone and my Macbook is hugely convenient.
    Any help would be much appreciated, we're now at the stage where we have 2 iMessage threads and a backup LINE group chat for when things are completely unfollowable due to every other message going to the duplicate thread.
    Thanks in advance.

    When you go to Settings>Messages do you see your Apple ID at the top?  Also, when you go to Settings>Messages>Receive At do you see both your email address and your phone number listed?

  • Can you run multiple versions of Message  on one computer, i.e. one for each phone line on our account?

    Does anyone know if you can run more than one Message+ on one computer, one for each of our phones?

        CATTULLOS
    Great question! The way to do it is, you will need to open up multiple browsers. (one for each phone number) The only thing you would need to do is log into www.vzw.com for each individual number to be able to send the text messages. Keep us posted let us know if this helps.
    JorgeO_VZW
    Follow us on Twitter @VZWSupport

  • How do you combine iMessage sent to phone number and email?

    I talk to someone who sends me imessages to my phone number from their phone, and also from their ipad to my email. Both phone number and email are under the same contact. But the mesages go into 2 different threads. Id like to combine them since being under the same contact they show up exactly the same in the messages list.. so i cant tell if im messaging the ipad or the phone..
    ideally id like to write a message to that contact and it would go to both their ipad and iphone...
    anyways.. how do I combine them?

    This is possible and you can also send and receive iMessages to your MacBook from one phone number without having to use any email address whatsoever. This also means you will have one chat thread with all of your messages not two.
    Anyone will tell you that I am a hardcore Apple Fan, however, sometimes they lack in the instructions area. For a while now I have had a problem with iMessages being sent from my MacBook. I could send an iMessage from my phone with no problem and my friend would receive it from my phone number however, the problem would arise when I would send a iMessage from my MacBook to to the same friend and a new thread would be created, so in essence she would have two different messages for me, one from my phone number and one from my email. After numerous attempts of contacting Apple Customer Service with no avail, I eventually figured it out on my own. I did aggrate some friends because I had to send messages relentlessly. In the end I found a solution and here are the instructions.
    You’re going to go into iMessage on your computer, go to messages in the top left, click on preferences and then click on accounts. Look under “you can be reached for messages at” you should see your email and or your phone number.
    If you do not see your phone number you need to add it to your account at this site. “https://appleid.apple.com/” click on manage your Apple ID and then sign in. After you sign in you will go to another screen and on your left you’ll see a list of choices click on phone numbers. Add your phone number and click save changes. It usually takes a few seconds for your iMessage account to update. Completely quit iMessage in the toolbar and then reopen it and go back into messaging preferences and then accounts.
    After that has been done your phone number should now be added to the “you can be reached for messages at” section. Click on your phone number and then uncheck your email address.
    Then go into your iPhone settings, messages, then scroll down to send and receive. Uncheck any email, only your phone number should have a checkmark, if your phone number does not have a checkmark... check it. You should receive a pop-up on your iPhone saying so-and-so’s MacBook is now using “insert phone number here” for iMessages.

Maybe you are looking for