compare the permeable line data and add

I have data like this

col1 col2

1 AB

1 CD

2 PQ

2 LM

3A

3 d

I got kicked out like that

1 ABCD

2 PQLM

3A

3 d

Please help me

Thank you very much

Hello

Welcome to the forum!

Whenever you have a question, tell what version of Oracle you are using.

You should post some examples of data in a form people can actually use.
For example:

CREATE TABLE     table_x
(       col1     NUMBER (4)
,     col2     VARCHAR2 (10)
);

INSERT INTO table_x (col1, col2) VALUES (1,   'AB');
INSERT INTO table_x (col1, col2) VALUES (1,   'CD');
INSERT INTO table_x (col1, col2) VALUES (2,   'PQ');
INSERT INTO table_x (col1, col2) VALUES (2,   'LM');
INSERT INTO table_x (col1, col2) VALUES (3,   'A');
INSERT INTO table_x (col1, col2) VALUES (4,   'C');

Also post the reulsts you want from these data, as well as an explanation of how to get these results.
Did you publish the results, but not an explanation. Why do you want to

2     PQLM

in the output rather than

2     LMPQ

? Or would be an acceptable?

Combining data from multiple lines in a single large chain is called chain aggregation . There are several ways to do it, depending on your version and exactly what you need.
Here's a way to string aggregation. It works in Oracle 9 (and more)

WITH got_r_num     AS
(
     SELECT     col1, col2
     ,     ROW_NUMBER () OVER ( PARTITION BY  col1
                               ORDER BY          col2
                       ) AS r_num
     FROM     table_x
)
SELECT     col1
,     REPLACE ( SYS_CONNECT_BY_PATH (col2, ',')
          , ','
          )     AS all_col2s
FROM     got_r_num
WHERE     CONNECT_BY_ISLEAF     = 1
START WITH     r_num     = 1
CONNECT BY     r_num     = PRIOR r_num + 1
     AND     col1     = PRIOR col1
;

The query above assumes that col2 never contains a «,» If so, then use another secondary channel never occurred in col2 as argument on SYS_CONNECT_BY_PATH 2nd. The 2nd argument of REPLACEMENT must be the same.

See other ways to string aggregation:
http://www.Oracle-base.com/articles/10G/StringAggregationTechniques.php

Published by: Frank Kulash, may 6, 2010 16:34

Tags: Database

Similar Questions

  • compare the permeable line data and add more than 1 column

    I have data like this

    col1 col2 col3

    1 AB XY

    UV 1 CD

    EF 2 OP

    2 GH QR

    3. I M

    4 J N

    I got kicked out like that

    Col1 Col2

    1 AB CD XY UV

    2 EF GH OP QR

    3. I J

    M 4 N

    I'm using oracle 10.2.0.4.My table is located in the remote database. Also my concatinated output is greater than 4000 bytes

    I tried the queries I can copied that did not work.

    option 1
    It gives the error ORA-22992: cannot use LOB Locators selected remote tables

    Request_id SELECT, to_clob (wm_concat (col2 | col3) as notes)
    FROM table_x
    GROUP BY col1

    option 2
    This works, but does not allow to add other columns
    WITH got_r_num AS
    (
    SELECT col1, col2
    ROW_NUMBER () OVER (PARTITION BY col1
    ORDER BY col2
    ) AS r_num
    FROM table_x
    )
    SELECT col1
    REPLACE (SYS_CONNECT_BY_PATH (col2, ',')
    , ','
    ) AS all_col2s
    OF got_r_num
    WHERE CONNECT_BY_ISLEAF = 1
    START WITH r_num = 1
    CONNECT BY r_num = r_num + 1
    AND col1 = col1 PRIOR

    Please help me

    Thank you very much

    Try this

    with t
    as
    (
    select 1 c1,'AB' c2,'XY' c3 from dual union all
    select 1,'CD','UV' from dual union all
    select 2,'EF','OP' from dual union all
    select 2,'GH','QR' from dual union all
    select 3,'I','M' from dual union all
    select 4,'J','N' from dual
    )
    select c1, ltrim(sys_connect_by_path(c2,','),',')||','||ltrim(sys_connect_by_path(c3,','),',') c2
      from (select t.*, row_number() over(partition by c1 order by 1) rno
              from t)
     where connect_by_isleaf = 1
     start with rno = 1
    connect by c1 = prior c1
       and rno = prior rno + 1
    
  • AppleScript set the string to date and add 30 minutes

    I am filling 2 boxes of time on a website in Safari, using Applescript from buttons selected by the user.

    My current Applescript is:

    Value dialog box to display the dialog box buttons ' when did your first departure case? {"07:30, ' 08:00, ' 08:30" "" "}

    definition of the first button returned of the result

    inputByName ("time 1", 0, start)

    the value of test for '07:30 ' - assuming that the user has selected '07:30 ' in the dialog box

    Test date - do not know how to assign 07:30 as an hour

    Finishing to test set + (30 * minutes)

    inputByName ("2", 0, finishing)

    The error return is number 'Invalid date and time date 07:30 < < script > >.' -30720

    Any help would be greatly appreciated!

    Thank you

    s

    You must use a complete date in the date/time of your machine settings.  A simple way is to simply get the current date (which returns a full date object) and manipulate that, for example:

    tell (current date)
      set its time to (7 * hours) + (30 * minutes)
      set someDate to it
    end tell
    return time string of someDate
    
  • The two lines EX90 and add speed dial

    My friends, I need help in this case, we replaced digital phone with EX90 new to our general manager. but there is some functionality was available on the old phone:
    1 - the old phone has buttons around the screen as a speed dial buttons for certain numbers of employees
    2 - the old phone has two lines one private and one is the direct line

    Here, he wants the same features on the EX90:
    1. I configured the favorite on the EX90 as a shortcut, but he wanted the speed Dial buttons appear directly on the screen for

    press about this directlry.
    2 - I have configured the EX90 on CUCM and added the second row but he only appeared, if there is a method to allow

    calls on the (direct and private calls on different lines) EX90

    Please I need your urgent help

    The DefaultPanel Option is only in more recent versions of TC software, I do not remember what version it appeared in, but it is there in the last TC7.1.3.  If you don't, you probably use an older version of software on your EX.

    It is located in the web interface under Setup, System Configuration, UserInterface touchscreen Panel default.

    The options are: none, last, list of contacts, MeetingList and keyboard.

    The option of contact list

    Another option (although, as for a simple speed dial) is the installation Service that puts a button in the upper left corner of the touch screen.  Note: Only facility Service 1 is available in the Panel even if you configure 5 of them.

    Wayne
    --
    Please rememeber the frequency responses and mark your question as answered as appropriate.

  • Use the project start Date and duration to calculate the end Date of project

    I'm trying to calculate the end date of the project in a report using the project end Date and time entered on the opportunity.
    For example, if the start date of the project filled an opportunity is 31/01/2009 and the length (integer) is entered on the opportunity is 5, the project end date is in the report must be 30/06/2009.

    I'm trying to TIMESTAMPADD forumaul allows you to add the duration (number of months) to the project start date
    This Fx works TIMESTAMPADD (SQL_TSI_MONTH, 12, '-used Custom Attributes ".) DATE_40)
    But if I try to replace the number twelve by the length (integer field) I get an error when you try to save: TIMESTAMPADD (SQL_TSI_MONTH, "-opportunity Custom Metrics".) S_INT_0, '-used custom attributes. DATE_40)

    Any ideas on how I can get this to work would be greatly appreciated.

    Hi, try this. It might solve your prioblem TIMESTAMPADD (SQL_TSI_MONTH, CAST (YOUR FIELD AS INTEGER), account. (' "Last modified")

    -John CRMIT

  • Do the photo album, date and time taken?

    Just downloaded all my iPhotos to Photos from the old to the new iMac. All the old photos transferred with the intact title (date and time). How to activate this in Photos? Added some new pictures for the first time to Photos and may not know how to make the title the date and time the photo was taken (without manually typing in the date and time).

    That s not a feature of Photos

    Users contributed scripts to perform these tasks - Script: batch changing the title to the Date of Capture -or http://www.oldtoadstutorials.net/No.P01.html

    LN

  • Is function like the function of date and time picker in the ICB 8.5?

    I need the function as "date and time picker control" used in activeX, but my operating system (windows 7 Bits without office software) is not the «Microsoft date controller» and time picker I am looking article in the internet which mention this register the MSComctl2.ocx in the windows\system32, but he could not operator in my operating system (it's not allow to save the controller). Help me, please.

    Already, I discovered that the problem on the service of DTP in the 64-bit Windows 7 could not used. Because, the DTP is 32 bits, it should use the administrator to register the 'mscomct2.ocx file' which must be replace in the % windows/SysWOW64 and used the 'mscomct2.ocx regsvr32.exe"in console windows.

  • If I have the resell, involving renewals and add as well as the original agreement?

    If I have the resell, involving renewals and add as well as the original agreement?

    Yes, when you as a partner to resell Solutions of Cloud Oracle you participate not only in the original agreement, but also of the renewals and additions to the service. As a reseller, you have the relationship with the end customer and you want that for too long the service continues.

  • How can I get rid of the file name, date and size of the photo in the upper left corner of the module develop when I'm not working on the photos?

    How can I get rid of the file name, date and size of the photo in the upper left corner of the module develop when I'm not working on the photos?

    All shortcuts are listed on the view > menu Info Magnifier.

  • What is the difference between 'place' and 'add files to download' in Muse CC?

    Hey guys... What is the difference between 'place' and 'add files to download' in Muse CC?

    Thanx

    You place the images to display on your site.

    You add files to download and make them available for download by visitors to your site.

    For example, you can add a PDF document, a Word document or whatever you want. These files are not displayable on your site, but you can link with the Hyperlink command to a button to make them available for download by visitors to your site.

  • Include the expected start Date and end Date for the management of SSHRC-Absence

    Is it possible to include the scheduled Start Date and end Date of project to SSHRC, management of absences with the type of leave is confirmed?

    Thanks in advance

    Hello

    In this case, you should disable the option the absence request, so that by default all sheets are confirmed and the user do not have to apply once leave as planned and then comply.

    You can see the id metalink - "How do I disable the State of Absence of R12 Absence Management Page [ID 786691.1]" to understand how to disable "Planned" option to request authorization for simple customization.

    It will be useful.

    Thank you
    Sanjay

  • Dynamics of the columns/line data adds forms (11.1.1.3) v/s (11.1.2.1)

    Hi all
    There was once an option in Hyperion planning 11.1.1.3 Dynamic add lines in the data form. I don't see this option in planning 11.1.2.1?
    Could you please suggest how we can grant the right to users to add dynamic add rows and columns in the form of data? or it's possible in 11.1.2.1?
    users want to have a feature of adding line in data forms (forms of planning)

    Thank you

    Published by: 842804 on August 17, 2011 12:49

    Do you mean 11.1.2 If Yes, then the ad hoc forms really take over to add lines they add many more features.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Dynamics of the columns/line data adds forms (11.1.1.3) v/s (11.1.1.2)

    Hi all
    There was once an option in Hyperion planning 11.1.1.3 Dynamic add lines in the data form. I don't see this option in planning 11.1.1.2?
    Could you please suggest how we can grant the right to users to add dynamic add rows and columns? or it is possible in 11.1.1.2

    Thank you

    What about ad-hoc analyses? Reading this: http://download.oracle.com/docs/cd/E17236_01/epm.1112/hp_user/ch04s02s03.html

    See you soon,.
    Mehmet

  • How to compare a Date with the current year data and member of period on FIX

    Hi experts,

    I have a Sun project that each Member is a project (P01, P02,...)
    and account IMGs who stores the information of each project (name, Start date, finished...)
    Finished Date member is of data type Date

    So how can write an IF condition below in order to be able to compare the end Date of the project with the members of the current year and period on FIX
    DIFFICULTY (@Descendants (Projects), Descendants (year-round), Descendants ("year Total")...)
    IF (@CURRMBR (Period)-> @CURRMBR (Year) < Project > - FinishedDate)
    Do something...
    On the other
    Do something


    Please help me on this. Sorry for my bad grammar. Please ask if there is something not clear

    Thank you very much
    Van Huy.

    Published by: Van Huy on 29 January 2013 01:14

    Published by: Van Huy on 29 January 2013 02:24

    Published by: Van Huy on 29 January 2013 02:25

    Published by: Van Huy on 29 January 2013 18:04

    Here's what I did. Post for which may later cover

    VAR FM; / * End of month of the project.
    VAR EXERCISE; / * Year of the project terminated * /.
    VAR CM; / * Capture the current month on FIX declarations * /.
    VAR CY; / * Capture current year on FIX declarations * /.

    DIFFICULTY (@RELATIVE ('year', 0), @RELATIVE ('period', 0), @IDescendants ("core projects")...)

    FY = @ROUND ('TGHT'-> ' NA contract "-> 'FY06'-> ' NA period" / 10000, 0);
    FM = @MOD (@ROUND ('TGHT'-> ' NA contract "-> 'FY06'-> ' NA period" / 100, 0), 100);
    / * For FY13 back 13... */
    CY = @JgetDoubleFromString (@CONCATENATE ('20', @SUBSTRING (@NAME (@CURRMBRRANGE (year, Lev, 0, 0, 0)), 2)));
    / * Value CM set based on perceived period on the DIFFICULTY of statement * /.
    IF (@ISMBR ("Jan"))
    CM = 1;
    ELSE IF (@ISMBR ("February"))
    CM = 2;
    .....
    ELSE IF (@ISMBR ("Dec"))
    CM = 12;
    ENDIF

    IF (CY< fy="" or="" (="" cy="=" fy="" and="" cm=""><>
    Do something...
    ON THE OTHER
    Do something...
    ENDIF
    ENDFIX

    Published by: Van Huy on 19 February 2013 23:10

    Published by: Van Huy on February 20, 2013 19:46

  • Comparing the virtual machine RAM and DataStore FreeSpace

    Hi all

    I'm trying to find out where VM is having more RAM compared to the data store space.

    I wrote the script for the same error below and is. More on is it possible I can print as VM name and name of data store after comparing the values. Please suggest.

    $vm = get - vm

    $vm | Select Name,MemoryMB,@{N='FreeSpaceMB'; E = {(Get-DataStore |)} Where {$_.} Name - eq ($vm. ({ExtensionData.Config.Files.VmPathName). Split('[]') [1]}). FreeSpaceMB}} | WHERE {$VM.memorymb - ge $_.} FreespaceMB}

    PowerCLI C:\ > $vm | Select Name,MemoryMB,@{N='FreeSpaceMB'; E = {(Get-DataStore |)} Where {$_.} Name - eq ($vm. ({ExtensionData.Config.Files.VmPathName). Split('[]') [1]}). FreeSpaceMB}} | WHERE {$VM.memorymb - ge $_.} FreespaceMB}

    Can't compare "4096" to "1621381 1621333". Error: "could not convert the.

    Value "System.Object []" type "System.Object []" type "System.Decimal. »

    At line: 1 char: 168

    {{+... ceMB}} | WHERE {$VM.memorymb - ge $_.} FreespaceMB}

    +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo: InvalidOperation: (:)) [], RuntimeException)

    + FullyQualifiedErrorId: ComparisonFailure

    Try like this

    Get - VM |

    Select Name, MemoryMB,

    @{N = "FreeSpaceMB"; E = {(Get-Datastore-nom ($_.))} ExtensionData.Config.Files.VmPathName). Split('[]') [1] | Select - 1 first). FreeSpaceMB}} |

    WHERE {$VM.memorymb - ge $_.} FreespaceMB}

Maybe you are looking for

  • How to use webcam on linux of kali

    I installk kali linux in my computer laptop 15-ac122tu I can't find webcam camera where am I find it? and if no driver to install for that then how his installation

  • How to abort Continuous Acquisition (which is set to acquire a constant number of samples per channel each iteration)?

    Hi all I would like to continuously acquire an input channel analog and, if necessary, be able to stop the acquisition as quickly as possible. I use a card NI USB-6289. I implemented a DAQmx (voltage) analog input task, set the clock sampling DAQmx '

  • disable the internal microphone

    Lenovo x 201 2985 F4U is it possible to disable the internal (built-in, integrated, whatever it's called) microphone on this unit? I have not been able to find a way without disabling the whole card.

  • camera automatic execution

    How can I get my camera auto run when I turn it on once it is connected to my computer, as it was

  • HP PHOTOSMART PRINTER

    MY PRINTER HP PHOTOSMART 6520 E - ALL - IN - ONE IS CONNECTED TO THE NETWORK AND EPRINT... FINALLY, BUT NOW ON MY COMPUTER IS IN OFFLINE MODE, AND I TRIED TO PRINT SOMETHING AND ALWAYS SHOWS OFFLINE, HOW DO I MY PRINTER TO PRINT ONLINE Help, please!