SQL: How to select the first telephone number for the Service to find?

Hi, can someone help me difficulty this query?

The problem is - ID is left with no phone number, a phone number and phone number. My requirement is to choose only first phone numbers and NULL values if a party who has more than one phone number. The query below is correctly picking of NULL values and unique phone numbers but also by selecting all the phone numbers for the id of group 13909 which has 3 phone numbers

It involves choosing the first phone number 416-890-0089 and limited to 416-960-8686, 647-456-3040

How to select only the first group id for the parties who have more than one phone number

Thanks in advance!

Select distinct p.party_id,
p.family_name,
p.given_name,
p.Status,
p.type,
above. Value,
PR. Role,
ad.unit_number,
ad.unit_identifier,
ad.street_number,
ad.street_number_suffix,
ad.street_name,
ad.street_type,
ad.street_direction,
ad. City,
ad.province_id,
ad.Postal_Code,
ad. Country_ID,
ad.postal_box_number,
ad.station_type,
ad.station_identifier,
ad.address_line_1,
ad.address_line_2,
ad.address_line_3,
ad.rural_route_identifier,
ad.rural_route_type,
ad. Status,
ad. ADDRESS_ID,
ad.attention

part p, ad address this contact_information, party_contact pc, pd, pr SR1CUST1.party_role party_address

Where
P.party_id = PD. Party_id
AND AD.address_id = PD.address_id
and p.party_id = pr.party_id
And (CI. Contact_Mode 't ='
Or CI. Contact_Mode is null)
AND P.party_id = PC. Party_id (+)
And PC. CONTACT_INFO_ID = this .contact_info_id (+)
AND AD.address_type = 'P '.
and P.type = 'B'
and pr.role = 'C '.
and p.family_name like '% Lew '.
and as p.given_name ' J %
Order by p.party_id ASC


Response


1478 null
1479 null
1577 null
1712 null
1822 null
6346-647-345-7384
6347 416-890-9384
6348 519-897-0089
6832 416-930-1265
8733 647-976-8923
13909 416-890-0089
13909 416-960-8686
13909 647-456-3040

You can simply use one group from all other columns that the phone number and then choose the min (phone_number):

select col1,
         col2,
         ...
         coln,
         min(phone_number_column)
from yourtables
where yourconditions
group by col1,
             col2,
             ...
             coln;

Tags: Database

Similar Questions

  • SQL: how to display the second string of the function in the Jobs table only if the function has more than one string.

    SQL: how to display the second string of the function in the Jobs table only if the function has more than one string.

    Hello

    You can use REGEXP_SUBSTR Oracle/PLSQL: REGEXP_SUBSTR function

    Select the function double REGEXP_SUBSTR('PUBLIC RELATION REPRESENTATIVE ','[^]+',1,2);

    Do you have any value of the column as no 2nd string?

  • Printer all in one HP3520 - how to select the wireless network and enter the WEP key?

    According to print my wireless network is detected.

    How to connect the! @# % printer $ fo the wireless network and enter the WEP key?

    Instructions on the HP site tell me to selet NETWORK on the printer control panel.  Well, there's a way to select the NETWORK from the control panel.  It is not an option for him.

    I downnloaded and installed the latest drivers.

    I have restored the default settings.

    How to select the wireless network and enter the WEP key?

    All of HP's instructions seem to be for a newer printer with a touchscreen.

    I want that the printer is connected to my main computer via the USB port.  I want to be able to print wireless phones and tablets.

    My 3520 is not a 'touch Screen' and it has wifi.

    However, the following work:

    Try to open the HP Deskjet 3520 icon, open the utilities tab, click on convert USB wireless, by following the steps on the screen.

    This leads me to believe that ONLY the wireless doesn't work.  I know now that the part of the sentence "Convert USB to wireless connection" is supposed to mean "works like USB and wireless.

    Thank you for your help

  • How to select the pieces of my image in black and white?

    How to select the pieces of my image in black and white? FOW example letter J or the circle or the two together?

    jaguar_growler_blur best8.png

    It's actually pretty easy, but I have to assume that you know a few basics in Photoshop

    (1) open your existing image

    (2) double click on the layer and the 'layer style' appears. In the mix if area set the sliders so the whites in the image disappears

    You will be left with just the black elements in design

    (3) duplicate layers

    and merge them together

    to give a standard layer

    (4) ctrl or cmd click on the layer to select and create a layer mask

    (5) you now have a mask of the image. Duplicate the layer, click alt or option, click on the layer mask to call

    (6) the blacks and the whites are not completely black and white for the use of levels to adapt to the absolutes

    (7) now you have to decide what you want to select. In this case, I chose the lettering and simply covered everything else to the top with black. You do this by lasso selection and fill and items when it's delicate brush just the details with a black brush "hard." .

    (8) at this stage, you can do what you want you have a layer mask. So you can color the text for example

    or place in a background color and apply a layer as Beveling effect

    Hope that makes some sense. It is much easier to do than to describe.

  • How to select the Type of industry 8.3 Professional P6

    Hi all

    According to the document to change the type of industry for 8.3 Professional P6, I had to go to P6, Application settings, general link.

    But in the P6 Web client to administrator > Application Configuration > General there is no option is available for the type of industry.

    Let me know, how to select the type of industry?

    You can see the OPINION score "How to change the Type of industry P6 P6 PPM (Professional), P6 EPPM E8.2 and later versions (Doc ID 1386047.1)".

    Also can you paste a screenshot here.

  • How to select the path to a file icon button to a table?

    I have a SYSTEM_PATHS table name. All physical access paths as 'where the forms of execution are located' or 'where performance reports are located' are stored in its ranks for example (C:\HRMS\FORMS\)
    I memorized the path of the icon files (.ico) inside. The forms of execution can take the path of the icons for the buttons of this table. And access the icon of the chosen path. I use forms 6i. Normally, I put the path of the icon files in the nerve to property of the button as (C:\HRMS\ICON\). But now, here, I don't have a path but its in the column of a table. How to select the path to a file icon button to a table using forms 6i?

    Hello Gul,

    have you tried

    set_item_property('Button name',ICON_FILENAME,);
    

    Concerning
    Marcus

  • How to select the same forms of color in the adobe flash program?

    How to select the same forms of color in the adobe flash program? for example, we assume that 10 forms of rectangle. 3 of them are red and others are green. I want to use only one method or click to select 3 of them. Please help me

    Thanks kunter

    You can use Ctrl + F.

  • How to disable the option to find my phone, if I phone 4S dead?

    How to disable the option to find my phone, if I have Iphone 4S dead? I turned on Itunes and I wanted to restore it, but it's impossible because I find my iphone app is on. Synchronization is impossible

    If the iPhone is dead, how do you plan on catering?

    You can disable FindMyiPhone by logging iCloud.com.

    -> iCloud: remove your device to find my iPhone

  • I tried to turn on windows defender and he said that there is an error. It will not turn back. Anyone with information would be a great help. How to start the service manually?

    I discovered that Windows defender is disabled. I tried to turn it back on, and he said that there is an error. How can I turn it back on? Anyone with information would be a great help. How to start the service manually? __

    Hello
     
     
    could a. you give us the exact error that you are experiencing?
    (b) also mention the error code, as well if it is listed.
    have c. you installed other software security like McAfee, Microsoft Security Essentials etc. ?
     

    Let us check if the service is set to automatic.
    1. Click Start-> run and type services.msc
    2. now, locate the service named Windows Defender,
    3. double click to bring up the Properties window.
    4. set the startup type to automatic
    5. click on apply, and then click Start
    6. click OK, and then click Close window Services/Local
     
     
    We hope to hear from you soon.

    Thank you, and in what concerns:
    Shekhar S - Microsoft technical support.

    Visit our Microsoft answers feedback Forum and let us know what you think.
    If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • I want to buy your security software by a live person on the phone, can you give me your phone number for customer service?

    Hello, phone number for customer service?

    What security software?

    I was not aware of Adobe, selling security software

    -What is in the set of Cloud http://www.adobe.com/creativecloud/catalog/desktop.html

  • How to control the service console in ESX?

    How to control the service console in ESX?

    http://www.Petri.co.il/5-critical-VMware-ESX-CLI-network-commands.htm

    http://download3.VMware.com/VMworld/2006/mdc9694.PDF

    http://download3.VMware.com/VMworld/2006/mdc9807.PDF

    http://download3.VMware.com/VMworld/2006/tac0028.PDF

    http://download3.VMware.com/VMworld/2006/tac9689-b.PDF

    http://download3.VMware.com/VMworld/2006/labs2006/VMworld.06.Lab04-performance-manual.PDF

    http://www.RTFM-ed.co.UK/

    PS: If you have found useful messages then please leave a few points

    André

  • How to start the service in order

    Hello

    I'm new to Hyperion.
    Can someone tell me how to start the service for HFM, planning and Essbase?

    Thanks in advance...

    Han

    Please read the following document:
    http://download.Oracle.com/docs/CD/E12825_01/EPM.111/epm_install_troubleshooting.PDF

  • How to select the subfolders to sync photo

    How can I select subfolders to synchronize photos from my Windows PC to my iPhone from iTunes?

    For example, I have a folder of photos called "2016" contains many different folders of different holiday and I want only to synchronize one folder, not all.

    You can choose the parent folder, and then select what first level subfolders in this folder will be included. I've broken down my main library by date in the files of the form \yyyy\yyyy-mm. For synchronization of my devices, I have a folder of images separated with a limited number of records album that I can choose for each device. These files contain copies.

    TT2

  • How to select the csv data stored in a BLOB column as if it were an external table?

    Hi all

    (Happy to be back after a while! )

    Currently I am working on a site where users should be able to load the data of csv (comma is the separator) of their client machines (APEX 3.2 application) in the Oracle 11.2.0.4.0 EE database.

    My problem is:

    I can't use an external table (for the first time in my life ) so I'm a little clueless what to do as the csv data is stored by the application of the APEX in a BLOB column, and I'm looking for an elegant way (at least SQL PL/SQL/maximization) to insert the data into the destination table (run validations by a MERGER would be the most effective way to do the job).

    I found a few examples, but I think they are too heavy and there could be a more elegant way in Oracle DB 11.2.

    Simple unit test:

    drop table CBC purge;

    drop table dst serving;

    create table src

    (myblob blob

    );

    create table dst

    (num number

    , varchar2 (6) str

    );

    Insert in src

    Select utl_raw.cast_to_raw (1; AAAAAA ;'|| Chr (10) |

    2; BATH; »

    )

    Double;

    Desired (of course) output based on the data in table SRC:

    SQL > select * DST;

    NUM STR

    ---------- ------

    1 ABDELKRIM

    2 BATH

    Does anybody know a solution for this?

    Any ideas/pointers/links/examples are welcome!

    / * WARNING: I was 'off' for about 3 months, then the Oracle - the part of my brain has become a bit "rusty and I feel it should not be so complicated as the examples I've found sofar ' * /"

    Haha, wonder about regexp is like the blind leading the blind!

    However, it's my mistake: I forgot to put the starting position setting (so 1, 2, 3,... was in fact the starting position, not the nth occurrence. duh!)

    So, it should actually be:

    select x.*
    ,      regexp_substr(x.col1, '[^;]+', 1, 1)
    ,      regexp_substr(x.col1, '[^;]+', 1, 2)
    ,      regexp_substr(x.col1, '[^;]+', 1, 3)
    ,      regexp_substr(x.col1, '[^;]+', 1, 4)
    ,      regexp_substr(x.col1, '[^;]+', 1, 5)
    ,      regexp_substr(x.col1, '[^;]+', 1, 6)
    from  src
    ,      xmltable('/a/b'
                  passing xmltype(''||replace(conv_to_clob(src.myblob), chr(10), '')||'')
                  columns
                    col1 varchar2(100) path '.') x;
    

    Note: that's assuming that all the "columns" passed in the string won't be lame.

    If one of them might be null, then:

    select x.*
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 1)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 2)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 3)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 4)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 5)
    ,      regexp_substr(ltrim(x.col1, ';'), '[^;]+', 1, 6)
    from   src
    ,      xmltable('/a/b'
                  passing xmltype(replace(';'||replace(conv_to_clob(src.myblob), chr(10), ';')||'', ';;', '; ;'))
                  columns
                    col1 varchar2(100) path '.') x;
    
  • How COUNT (*) SELECT all first before returning SELECT *.

    Our interface involves a grid filled by a SELECT query. The records are retrieved via a complex query with many tables involved and spent many filtering parameters. A simplified example:

    SELECT col1, col2,... colx

    OF tab1 tab2, tab 3 t3 t2, t1, etc.

    WHERE

    T1.Key1 = t2.key1

    and t2.key2 = t3.key2,

    and... etc.

    and t1.coldate > p_FilterDateFrom

    and t1.coldate < p_FilterDateTo

    and t2.somefield = p_FilterSomeFilter

    and t3.someotherfield = p_FilterSomeOtherField

    and... etc.

    Generally, the user enters parameters, so a small, manageable resultset is returned.

    But sometimes the user will enter the parameters that returns thousands of lines. As a result, the frontend in IE makes a break from time to time say ' Stop running this script? A script on this page slows down your web browser to run slowly... »

    I would like to run the above example query with a COUNT (*) SELECT all first before running the actual SELECT col1, col2, col3. This way if the rows returned exceeds a certain threshold, say, 500 lines, I could pop a message saying "more than 500 rows will be returned. Do you want to continue? ». If the user clicks Yes, then I go ahead and perform the actual query and fill the grid. If the user clicks on no, then the user gets a chance to adjust its settings.

    Y at - it an easy way to do short of coding (essentially) two versions of the same complex query, one for "SELECT COUNT (*)" and the other for "SELECT?"

    Thank you.

    Hey, Justin (or someone else). I quite agree with you on this... However, just to play the lawyer of the devil for a second... (or maybe not... so why I asked)

    The COUNT (*) Analytics as a separate and additional column has been added to the query would be a significant hit to the performance? I have simply discarded with a little, but set of samples was not big enough - I'll try a larger, later when I get time.

    something like:

    1. SELECT *.
    2. DE)
    3. SELECT col1, col2,... colx, count (*) NTC)
    4. OF tab1 tab2, tab 3 t3 t2, t1, etc.
    5. WHERE
    6. T1.Key1 = t2.key1
    7. and t2.key2 = t3.key2,
    8. and... etc.
    9. and t1.coldate > p_FilterDateFrom
    10. and t1.coldate<>
    11. and t2.somefield = p_FilterSomeFilter
    12. and t3.someotherfield = p_FilterSomeOtherField
    13. and... etc.
    14. order of something)
    15. where rownum<=>

    So, you can then enter the total number of any line (probably the first) and know how much you have?

    I'm sure it's more work than simply without... However, I guess that the real question... How much better it is than to the separate account? (if applicable)

Maybe you are looking for

  • Satellite 1800 - 814 began to disable when you only run Windows update

    I HAVE NOT IT IS AN OLD MACHINE, BUT HE MADE WHAT I NEED 2 DO IT STARTED 2 TURN OFF WHEN I TRY AND DO SOME THINGS WITH HIM LIKE RUNNING WINDOWS UPDATE, DISK CLEANING, DEFRAGING, IT CAN ANY BODY HELP ME HOW SA MAKES ME NUTS

  • Matrix problem

    A matrix that I calculate keeps display in an imaginary form i.e. 90 + 0i, 75 + 0i, even if I selected all mathematical operations which is the matrix to be "real matrix. Any ideas?

  • Is there a simple list with what can do the 8600 printer?

    Is there a list somewhere with all the features of HP Officejet Pro 8600 explained or mentioned briefly? Stuff like 'you can automatically scan several pages and send it to an e-mail address' and 'you can print with your smartphone with the help of a

  • Windows will not read the disc media

    For some reason, windows will not read dvd or cd or the floppy one and the flash drives or cards of the camera with a usb drive. What would cause this and how then I get back to work? All media works on the other pc.

  • PIX firewall problem

    I have two servers, one in pix inside and the other in the demilitarized zone. I wanted to set them up so that they can communicate with routers and switches Located outside the pix firewall. My inner Server works fine, able to go Internet and able t