Multiple values per line

I have a table of the format:=
person_id number,
phone_type varchar2,
phone_number varchar2.
Eg:=
person_id,phone_type,phone_number
1 home 123456
1 work 456789
1 mobile 989076554
2 home 456789090
3 home 4567890
3 fax 345678
3 mobile 23456789
I want to return the data in the format:=
1 home 12345 work 45678 mobile 989076554
2 home 456789090
3 home 4567890 fax 345678 mobile 23456789
Any suggestions? What if the number of phone_types is not fixed?

Since procedural approach has been given already, here is an alternative with SQL statement. SQL> Select * From phones;
PERSON_ID PHONE_TYPE PHONE_NUMB
         1 home       123456
         1 work       456789
         1 mobile     989076554
         2 home       456789090
         3 home       4567890
         3 fax        345678
         3 mobile     23456789
7 rows selected.
SQL> Select person_id, max(decode(rn, 1, phone_type, null)) phone_type1,
  2               max(decode(rn, 1, phone_number, null)) phone_num1,
  3                    max(decode(rn, 2, phone_type, null)) phone_type2,
  4               max(decode(rn, 2, phone_number, null)) phone_num2,
  5                    max(decode(rn, 3, phone_type, null)) phone_type3,
  6               max(decode(rn, 3, phone_number, null)) phone_num3
  7  From
  8  (Select person_id, phone_type, phone_number,
  9   row_number() over (partition by person_id order by person_id) rn
10   From phones)
11  Group By person_id
12  /
PERSON_ID PHONE_TYPE PHONE_NUM1 PHONE_TYPE PHONE_NUM2 PHONE_TYPE PHONE_NUM3
         1 home       123456     work       456789     mobile     989076554
         2 home       456789090
         3 home       4567890    fax        345678     mobile     23456789Caveat1: This approach must know the maximun number of PHONE_TYPES upfront.
Above coding works for 3 phone types. If there are more, add more max(decode())
clauses to the SQL.
Caveat2: SQL uses analytical function, you should have Oracle 8i or above to run this SQL.
Thx,
Sri

Similar Messages

  • "Scatter" Chart with Multiple Values per Date

    APEX Gurus,
    I need to plot a chart with multiple y-axis values along the x-axis.
    Here's an example:
    X-Axis (Date) Y-Axis (Number)
    1-JAN-07 1
    1-JAN-07 2
    1-JAN-07 3
    2-JAN-07 1
    2-JAN-07 2
    3-JAN-07 1
    Right now, APEX displays the X-axis (Date) as separate values on the x-axis. But I want all three 1-JAN-07 values to line up vertically under x-axis. I am currently using a line chart for this. And it displays a "dot" for each value (depending on my max rows value).
    Any insight would be much appreciated! And thanks in advance!
    Susan

    You can try using this charting tool for generating scatter charts:
    http://htmldb.oracle.com/pls/otn/f?p=31517:58
    Denes Kubicek

  • Multiple Values per Key - PLEASE HELP!!

    hi. im trying to setup a TreeMap so it contains multiple values for each key using a List to store these values and a string as a key to reference them. however, although it compiles, i recieve a ClassCastException: java.util.ArrayList error when it runs. heres some of my code:
    Map resultRelation = new TreeMap();
    List list = new ArrayList();
    list.add(value1);
    list.add(value2);
    resultRelation.put(Key, list);
    i cant seem to find much useful information on this sort of thing. any help would be appreciated.

    well after hours of labouring, it turns out that the code i posted is working but the problem is actually to do with printing out the values stored in the array. it was rather stupid of me but before i had created a print method which printed the key and its value from the map, assuming the value was one string not a List, and i hadn't updated it =) so the ClassCastException error was occuring because i was trying to cast the value (which is really a List) to a string in order to print it.
    heres my updated printRelation method code as follows:
    private static void printRelation(Map relation) {
    Iterator keyIter = relation.keySet().iterator();
    Iterator valueIter = relation.values().iterator();
    while(keyIter.hasNext() == true) {
         String primaryKey = (String)keyIter.next();
         List foreignKey = (List)valueIter.next();
    ConsoleIO.out.print(primaryKey); // ignore the ConsoleIO stuff. the key prints no prob.
    Iterator iter = foreignKey.iterator();
    while(iter.hasNext() == true) {
    String value = (String)iter.next();
              ConsoleIO.out.print(value);
    at the moment im only adding 1 value to the List as shown in my previous post. e.g.
    list.add(foreignKey1);
    all this works BUT im getting the wrong results. instead of printing out the key and only its values, its printing out the key and ALL the values from the text file im using. i think its either got something to do with my while loop or my casting of the List but this is all new ground for me =)
    thanks.

  • Multiple entries per line on MTRs

    Hello,
    Can anyone tell me what the multiple line items are when running an MTR?  I previously though that the "extra" line entries were the various paths that an ICMP packet may take to the destination, but I have observed that the last hop will occassionally contain multiple entries, as well. This is confusing me in my newbness.  Can anyone help provide some insight into this?
    Thanks,
    Kevin
    Sample MTR (IPs have been changed to protect the innocent).
    1. 10.16.224.1                                                                                                                            0.0%    69    0.3   0.3  
    2. 10.7.255.8                                                                                                                              0.0%    69    0.3   0.4  
    3. 10.7.127.135                                                                                                                            0.0%    69    0.4   0.7  
    4. 10.11.62.2                                                                                                                             0.0%    69    0.7   2.2  
    5. 10.15.107.128                                                                                                                          0.0%    69    1.4   8.1  
    6. 10.15.96.113                                                                                                                           0.0%    68   46.4  37.2  
        10.15.101.150
        10.15.105.18
    7. 10.15.101.154                                                                                                                          0.0%    68   90.4  66.9 
        10.15.96.120
        10.15.96.54
        10.15.100.67
    8. 10.15.100.136                                                                                                                          0.0%    68   84.5  94.4 
        10.15.108.119
        10.15.101.152
        10.15.108.2
        10.15.96.110
        10.15.108.117
        10.15.101.144
        10.15.96.80
    9. 10.15.102.114                                                                                                                          0.0%    68   78.8  88.7 
        10.15.96.217
        10.15.108.117
        10.15.96.219
        10.15.108.115
        10.15.96.223
        10.15.96.221
        10.15.108.0
    10. 10.73.188.43                                                                                                                            0.0%    68   85.0  86.4 
        10.15.96.217
        10.15.96.221

    Hello,Can
    anyone tell me what the multiple line items are when running an MTR?  I
    previously though that the "extra" line entries were the various paths
    that an ICMP packet may take to the destination, but I have observed
    that the last hop will occassionally contain multiple entries, as well.
    This is confusing me in my newbness.  Can anyone help provide some
    insight into this?Thanks,KevinSample MTR (IPs have been changed to protect the innocent).
    1.
    10.16.224.1                                                                                                                          
    0.0%    69    0.3   0.3  
    2.
    10.7.255.8                                                                                                                            
    0.0%    69    0.3   0.4  
    3.
    10.7.127.135                                                                                                                          
    0.0%    69    0.4   0.7  
    4.
    10.11.62.2                                                                                                                           
    0.0%    69    0.7   2.2  
    5.
    10.15.107.128                                                                                                                        
    0.0%    69    1.4   8.1  
    6.
    10.15.96.113                                                                                                                         
    0.0%    68   46.4  37.2  
        10.15.101.150
        10.15.105.18
    7.
    10.15.101.154                                                                                                                        
    0.0%    68   90.4  66.9 
        10.15.96.120
        10.15.96.54
        10.15.100.67
    8.
    10.15.100.136                                                                                                                        
    0.0%    68   84.5  94.4 
        10.15.108.119
        10.15.101.152
        10.15.108.2
        10.15.96.110
        10.15.108.117
        10.15.101.144
        10.15.96.80
    9.
    10.15.102.114                                                                                                                        
    0.0%    68   78.8  88.7 
        10.15.96.217
        10.15.108.117
        10.15.96.219
        10.15.108.115
        10.15.96.223
        10.15.96.221
        10.15.108.0
    10.
    10.73.188.43                                                                                                                          
    0.0%    68   85.0  86.4 
        10.15.96.217
        10.15.96.221
    Hi Kevin,
    If you see how to read MTR output just check the below example which has the heading
              ACME (0.0.0.0)                                                Sun May  4 20:08:00 2008
    Keys:  Help   Display mode   Restart statistics   Order of fields   quit
                                                            Packets                                                                        Pings
      Host                                              Loss%                                                     Snt   Last   Avg  Best  Wrst StDev
      1. 192.168.2.1                              0.0%                                                        24    1.9   2.1   1.1  13.8   2.6
      2. 192.168.1.1                              0.0%                                                        24    2.8   2.4   1.9   3.2   0.4
      3. 194.19.98.129                          95.7%                                                     24   22.4  22.4  22.4  22.4   0.0
      4. 195.204.200.13                        4.2%                                                       24   29.4  24.3  16.6  36.2   5.2
      5. 194.19.81.37                             0.0%                                                       24   36.5  32.1  19.3  48.7   6.7
    The above output shows the packet loss occured while the device coming in between to destination with ping responce of last,latest and avg fromwhere we can come to conclusion where is the problematic area like if you see the above output router at 194.19.98.129 is having haigh packet loss,it can be problem with routing protocol, if the lag is a bad route, cached arp, or bad routing tables.
    Hope to Help !!
    Ganesh.H
    Remember to rate the helpful post

  • How to fetch the condition value per line item in PO o/p

    Dear Experts ,
    I need to fetch the value of the all valid condition types in the PO item , for its o/p .
    For this i should know
    1.what all are the  condition types involved in the item .
    2.what is the condition rate
    3. what is the condition value .
      Pleas etell me how do i fetch this data ??
    Thanks in advance
    Regards
    Anis

    Hi Anis,
    At first collect the doc.condition-KNUMV from EKKO table.
    Later enter the above doc.condition no in KONV and KONP to get the details.
    Regards
    Ramesh Ch

  • Displaying multiple values per row in a shuttle, each separated with a tab

    In a shuttle, you normally have a flat list with single values that are displayed: Value=Niels, Returnvalue=1
    What I would like to achieve is the following: Value=Niels<tab>Manager<tab>Ratingen<tab>Germany, Returnvalue=1
    Each <tab> represents a tab to align each column.
    This behaviour is possible in Access, but is it also possible with APEX / HTML?
    I already checked the HTML "pre" tag, but that didn't do the trick when utilizing it in a shuttle.
    Edited by: [email protected] on Jan 13, 2010 5:31 AM

    [email protected] wrote:
    In a shuttle, you normally have a flat list with single values that are displayed: Value=Niels, Returnvalue=1
    What I would like to achieve is the following: Value=Niels<tab>Manager<tab>Ratingen<tab>Germany, Returnvalue=1Can you cheat and concatenate values together to make one value? They could be parsed after the fact into individual components.
    Display will probably be a problem. Tabs are notorious for rendering in different ways in different environments (in editors, through HTML, when printed, etc). Figuring out a way to delimit by spaces might be better for display purposes
    Another option is to write your own shuttle application - pobably not practical :(

  • Retrieving the Change Texts per Line Item (Purchase Order) - Very urgent

    Hi,
    How do you retrieve the Change Texts per Line Item (Purchase Order).
    Table T166T does not list these values per line item.
    Please help. This is very urgent & important.
    Best Regards,
    John

    if you are lookin out for change of item texts ...
    then use the function module ... READ_TEXT.
    and 2 tables r used ... STXH and TLINE ....
    double click on item data ...
    goto PO TEXT tab ....
    double click on text ...
    from menu ...
    goto header ... u'll get 4 fields that u need to consider ...
    TDID
    TDOBJECT
    TDHEAD
    TDNAME
    ALL THESE U'LL FIND IN  STXH
    ITEM TEXT is stored in TLINE
    Edited by: anjali rana on Mar 5, 2008 4:55 AM

  • Idoc per line item in SO

    Hi
    I have configured output type at the line item level for Sales orders. When I have save a sales document, the ORDERS05 Idoc type is triggered. It contains segments for all the line items.
    Can we have the Idoc generated with only line item, for which the output type is created, even if the Sales Order has n number of Items?

    Hi,
    What I want is to get the net value that is displayed in the conditions tab of VA01/VA02
    before saving the sales orders. Is there a way to do that or an FM that computes for the
    net value per line item.Thank you!

  • Multiple values in a user record field and Address Book

    Hi
    I'm working out a method of importing multiple users into an LDAP directory on OS X 10.4.4, and I've hit an interesting snag.
    When you export a user from Workgroup Manager, any fields in the user record that contain multiple values (multiple email addresses, work phone numbers, etc) contain their values separated by commas. For example:
    username::::[email protected],[email protected]:::
    However, when I view that LDAP entry in a networked Address Book, it only displays the first value, not the second or subsequent values. I've changed the Address Book template to specify multiple emails/phone numbers, but that doesn't do it.
    If I create my own import file, and pull it into Workgroup Manager, they import correctly into the user record, so I don't think I'm doing anything wrong on the server side.
    Does anyone know how to make Address Book display all the values?
    Thanks
    Matt

    if i'm not remembering read stuff wrong, these fileds have quite alot of limitations. and i think multiple values per field is such a limitation.

  • Sum of values exceeds the allowed maximum value per service line

    Hi Guys,
      While creating PO wrt to contract : I get error msg : Sum of values exceeds the allowed maximum value per service line Message no. SE402. Can I change it to warning or should I bifurcate one line into two , as the value is very big. Totalling to 11 characters excluding decimal. Its like xxx,xxx,xxx.xx inr.
    Regards,
    SK

    Hi,
       For service line items, the maximum allowed limit is 999999999.99 (total 11 digits including 2 decimals) as per design. If you want more than that, you may split the service in to two line items.
       The note:   1810281 - System does not issue error message SE 402  explains the logic.
    Regards,
    AKPT

  • Multiple Selection multi-line per choice

    I have a bunch of multiple selection items which are all the same, so I copied and pasted them where I wanted them. The pasted ones are taking up two to three lines per choice (one word per line) even though they are very short and the original that I copied from only takes one line each. Does this mean I have to do each one manually? Why are the copied ones different from the original? Thanks!

    Hi,
    It sounds like a bug, since this shouldn't be happening.  However I tried to reproduce the problem, but couldn't.  It's probably a bug, that specific to your choices labels.  Could you share your form to me ([email protected]), so I can take a look at the specifics?  Once I can see it, I can provide some guidance about the issue and how to work around it (if posisble) until we've fixed it.  You can share a form by clicking the share button, and then clicking add collaborators.
    Thanks,
    Todd

  • Multiple Value Based hierarchies per MOLAP dimension

    Hi,
    a) Is it possible to have multiple value based heirarchies in a single MOLAP dimension in OWB and deployed to analytical workspace ?
    Are there any pitfalls, that we need to be aware of...
    b) Can we have a mix of Value and level based heirarchies per dimension ?
    Thanks in advance,
    Chakri

    Hi Chakri
    Yes, you can have multiple value based hierarchies and also a mix of value/level based.
    Cheers
    David

  • Sales order with line items having multiple values in multiple currency

    Please suggest solution for creating sales order having line items with multiple values in multiple currencies.
    e.g. Line Item A Qty/1 No,  value 100INR100$100EUR. Customer wants all three values to display at sales order line item level and create billing in 3 currencies.

    Hi,
    As far as my understanding it may be possible round the solution,
    For 1 company code we can able to maintain 3 currancies,
    1 currancy is hard currance & other two are dual currancies.
    Create sales order with 3 line items having 3 diffrant currancies
    Spilt invoice on the basis of currancy
    Last pass to this invoices to accounting.
    Whole process is
    Sales order >>> Delivery >>> Invoice 1, Invoice 2, Invoice 3(Split invoice on basis of Currancy).
    Consult with FI Team they will tell you about dual currancy & hard currancy
    Kapil

  • In Classificaiton datsource - Error "Characteristic has multiple values"

    Hello All,
    I have created classification data source 1CL_OMAT001 for material ATTR.. When adding the "PRODLINE" as one of characteristic I am facing this error "Characteristic has multiple values". I want to extract the Prod line to BW after this extraction.
    Adding info, This PRODLINE is under a class "BUSINESS LINE". It is a only component of this class type, If i add characteristic of any other type say engineeering class.
    Please help. If any information u want from me let me know.
    Regards, Karthik

    Hello Karthik,
    classification allows to assign multiple values for one charateristics to the same classified object, if the characteristic is defined accordingly (see please transaction CT04). Because only one value per characteristic and object can be extracted, CTBW checks the definitions of the characteristics you are assigning to a datasource. It refuses to assign characteristics, which allow multiple values, to a datasource. That's what you have observed.
    In some cases characteristics allow multiple values for technical reasons, but actually only one value is assigned when objects are classified. For such cases you may turn the observed error to a warning (see please SAP note 350296). The first found value will be extracted. Further values would be ignored.
    If you need to extract multiple values, you may use a solution like described in SAP note 1002105.
    Regards,
    Rolf

  • Passing Multiple Values from a worksheet to PL/SQL function.

    Hi All,
    Is there any way to pass multiple values selected in a worksheet to a PL/SQL function ?
    I will try to explain the scenario:
    We have a crosstab report that showing all the customer details, deposit sum of a customer in each date in a date range selected. With the customer details we are showing the Rank of a customer based on the deposit in the latest date selected. Filtering is based on the rank, ie Top50 or Top60 etc.( As I said rank is calculating based on the deposit in the latest date).This is working fine.
    Now the new requirement is to : For example, in Top50 report, list all the customers, who were in the Top50 list, in any of the dates selected. We are able to display the daywise rank, but when giving a condition like daywiserank <= 50, the result becomes uncertain. Some blank lines, wrong amounts etc..
    As a work around we tried to find out the rank in a PL/SQL function. But the issue there is : we have some multiple value parameters used in the worksheet.
    Is there any way to pass multiple values selected in a worksheet to a PL/SQL function ?
    Or any other work arounds for the scenario explained?
    Reagrds,
    Jeneesh

    Hi Russ,
    Thanks for the response.
    Russ Proudman wrote:
    1. I thought there was an analytical function similar to rank - or maybe an option of rank - that if there are duplicate records to have them all considered the same rank. So if you had 3 records all the same as rank=2 then a condition saying where rank=2 would return the 3 records. You could check into this.
    We are already using DENSE_RANK. But the issue is the output contains incorrect null values nd repeated rows.
    We got it solved as I explained in the previous post. But will that AGGREGATION MODE setting ( Which discoverer says - not recommended) have any issue? I mean side effects?
    Russ Proudman wrote:
    2. Another thought is that you can create a PL/SQL routine - that's called from a SQL function registered in Discoverer - where a table is created that does the first part of your query. Then a worksheet is created to use the data from that table. So, in essence, the table would have your top50 ranked customers. Then you can write any kind of worksheet against that table. However, DBAs are loath to allow tables - that they didn't create! - many times in a PROD environment.
    Here also the same problem will occur: as the top 50 will depend upon the parameters. I cannot pass those parameters to PL/SQL Function.And storing the top50 ( itmay be top100 or to 150 also) for all combinations of the parameters is impossible
    Russ Proudman wrote:
    3. Finally, are you sure you're rank function is correct in that if you're getting blank lines, maybe the 'over' part is not considering all columns needed to determine the rank?
    Yes the query we are using is correct. The output QUERY of discoverer gives correct results in Sqlplus.
    Regards,
    Jeneesh

Maybe you are looking for

  • NFE 2.0 - Contingencia

    Bom dia, Estou testanto do processo de contingencia para a versão 2.0 do XML da NFE. Através do monitor da NFE (J1BNFE) eu coloco em contingência o local de negócio. Flego o primeiro campo MS Down e coloco o motivo da contingencia no campo Mt Cont MS

  • Unable to specify username password for emulator sessions on MAC OS 10.5.2

    We have a strange issue at one of our customers. When the want to start an emulator session the login dialog box does not accept keystrokes when started from a MAC-client with MAC OS 10.5.2 (X11 version 2.1.1). People cannot enter their credentials a

  • What all switches do we require for ccnp

                       I am doing training for Ccnp best institute in Delhi , networers zone (http://networkerszone.com/), suggest me what all series switches access is required for ccnp, apart from Cisco 6500, cisco nexus, cisco 3770 and 2960.

  • Ouvrir les fichiers pdf dans Adobe Reader

    Sur mon iPad, lorsque je reçois un fichier pdf par courrier électronique, il s'ouvre instantanément en coup d'œil. Moi je voudrais pouvoir l'ouvrir dans Adobe Reader afin de pouvoir utiliser les outils d'annotations. Pouvez-vous m'indiquer comment fa

  • Window to Continue Free XI Trial Pops Up Every Hour!

    I downloaded the AdobePro XI free trial, due to *numerous* problems with the latest CreatePDF upgrade.  Now I am getting a screen that pops up constantly asking if I want to continue the trial or purchase.  How can I make this stop?  So far, it's pop