concatenate the strings in cumulative mode

Dear Experts,

I have a table that stores orders information placed by customers. It stores Customer Id, order Id, order Date, and Date sent. I need to write a sql query that gives me the previous history / order date and ship date in the format shown below. Is there more than 10 orders per customer then I need only the previous order of 10 and the shipping date.



C1O328012013; 0101201330012013; 07012013
C1O418042013; 28012013; 0101201322042013; 30012013; 07012013
C1O514072013; 18042013; 28012013; 0101201316072013; 22042013; 30012013; 07012013

Before posting my question here, I tried using lead, lag and listagg functions but I am unable to frame the query that produces the result I'm looking for. Any help would be greatly appreciated.

I'm using oracle 11g.

Thank you.

You can also...

Select Customer_ID


, trim (both ';' of sys_connect_by_path (to_char (order_date, 'ddmmyyyy'),' ;')) h_order_date))

, trim (both ';' of sys_connect_by_path (to_char (Shipped_Date, 'ddmmyyyy'),' ;')) h_Shipped_Date))


(select Customer_ID


lag(order_date,1,null) on order_date (order by order_id)

, lag(Shipped_Date,1,null) over (order by customer_id) Shipped_Date

row_number() over (order by order_id) rn

from your_table t


Start by rn = 1

connect by prior rn = rn - 1

Using the MODEL clause:

Select customer_id


rtrim (h_order_date, ';') h_order_date

rtrim (h_shipped_date, ';') h_shipped_date



partition (customer_id)

dimension (row_number() over (order by order_id) rn)

measures (order_id, order_date, shipped_date, h_order_date cast (null as varchar2 (256)), climb (null as varchar2 (256)) h_shipped_date)


h_order_date [rn > 1] order by rn = to_char (order_date [cv () - 1], 'ddmmyyyy') | « ; » || h_order_date [cv () - 1]

, h_shipped_date [rn > 1] order by rn = to_char (shipped_date [cv () - 1], 'ddmmyyyy') | « ; » || h_shipped_date [cv () - 1]


Tags: Database

Similar Questions

  • How to concatenate the string with a digital command?


    How to concatenate the string with a digital command?

    Thank you.

    I think I forgot to add the semicolon, what you can do is, drag the CONCATENATE function and add semicolon.

  • concatenate the strings comand...


    I must repeat that channels below a large part of the time (ON SQL MORE);

    Now I do with comand of copying and pasting each string, but it is very unconfortable.

    How to concatenate the string in a string only, or max 2 strings?

    .. .so I need that I copy/past comand to do all operations of this...


    create user Patrick identified by loan;

    Grant connect, create session, imp_full_database to Patrick;

    GRANT to CREATE ANY WORK to Patrick;

    modify user quota unlimited Patrick on the SYSTEM;

    grant unlimited tablespace to mx;


    sqlplus command line allows you to paste together multiple orders (lines) and it then executes sequentially.

    Hemant K Collette

  • Concatenate the strings from VISA

    Hello people,

    I'm still fairly new to LabView, please bear with me.

    I'm interested in doing a Subvi, which will receive bytes on a VISA from serial port and write each line to a greater (concatenated) string, so it can later be stored in a file. In simple terms, I want to save all the data on the serial port for 8 tests to be completed. There will be 6 cases of this in the parent VI, so he needs be modular.

    I expect a series of 8 channels of the source serial communication, each line begins with "Success" or "Failed" then the test. for example:

    Past test1

    Failure of test2

    Past of test3

    Past of test4




    The current method I use must react when there are present bytes in the buffer in series, and then identify a match (currently it only identifies a match of 'Success').

    Is it possible to get a match for the substring to 'Success' OR 'failure '?

    How can I place all these strings on a chain? Concatenation of strings do not work because I'm having the same input string of the VI...

    Any help/input would be welcome, thank you.

    Here is a basic example of using to concatenate strings. Since it is always very difficult to know if you call your Subvi several times or if you call once and want to to read all the results I won't comment much more on it. This example would read all the results and the output format string you want to write to a file later or do whatever you want with it. The basic constructs of what you will need are illustrated here. How to encorporate in your application will be difficult to say without any code beyond the wick you have posted.

  • How to concatenate the string of normal worksheet to srting


    I try to concatenate string worksheet to sring normal, but she cannot concatenate... here, I have attached my program for your firm .the support cannot be CONCATENATE.


    Your channel is get concatenated but is getting added to the new line. If you exapnd your channel indicator, you can see ")" in the new line.

    Remove the \n character and you will get the desired output.

  • How do to concatenate the strings having single quote and ampersand

    Hi all

    I have a task to concatenate two columns under SID - SNAME.

    Input parameter is: sid. We can pass multiple parameters: sid


    Insert into TABLE1 (SID, SNAME) values (1, 'SURF UP');

    Insert into TABLE1 (SID, SNAME) values (2, 'GNLV STYLE & KEY');

    Insert into TABLE1 (SID, SNAME) values (3, 'ESSENTIALS NORTH & SOUTH');

    Insert into TABLE1 (SID, SNAME) values (4, "Of Ora");

    Select * from TABLE1;

    1Of THE SURF's UP

    Expected results

    1. with the setting entry: sid in (1,2)

    Output: 1 - SURF to the TOP, 2 - GNLV STYLE & KEY

    2. with the setting entry: sid in (1,2,3,4)

    Output: 1 - SURF to the TOP, 2 - GNLV STYLE & KEY, 3 - ESSENTIALS NORTH & SOUTH, 4 - ora

    I tried to use the below query,

    Select (select RTRIM (xmlagg (xmlelement (c, sid |')))) -' || SNAME | (",")) .extract ('/ / text()'), ',')

    AS concatenated FROM table1 where «,» | : para. ',' like '%', | SID | %') as double concat;

    What I get for output is as below:

    1 SURF & apos; S upwards, 2 - GNLV STYLE & amp; TREND

    I'm not handling apstrophe and ampersand correctly.

    Can you please help me.

    Thank you

    What I get for output is as below:

    1 - SURF to the TOP, 2 - GNLV STYLE & TREND

    I'm not handling apstrophe and ampersand correctly.

    Yes. This is what happens when you use a method that is not understood.

    The answer to your question is dependent on the version and already well covered in the FAQ.

    See 'Channel aggregation' in Re: 4. How can I convert rows to columns?

    If you are on 11.2 and beyond, use LISTAGG function.

    Regarding your present attempt, since you are extracting text() nodes on an aggregate of XMLType, the result is still a valid XMLType and therefore shows the XML characters reserved in their forms with escape sequence.

    If you want to stick with the XML approach, from 11.1, is the right way to handle this situation:

    SQL> select rtrim(
      2           xmlcast(
      3             xmlagg(
      4               xmlelement(e, sid ||' - '||sname||',')
      5             )
      6             as varchar2(4000)
      7           )
      8         , ','
      9         ) as concatenated
    10  from table1
    11  where ',' || '1,2,3' || ',' like '%,'|| sid || ',%' ;

    In earlier versions, use either:

    select rtrim(
                   xmlelement(e, sid ||' - '||sname||',')
               , '//text()'
             , 1
           , ','
           ) as concatenated
    from table1
    where ',' || :para || ',' like '%,'|| sid || ',%' ;


    select rtrim(
                   xmlelement(e, sid ||' - '||sname||',')
               , '//text()'
           , ','
           ) as concatenated
    from table1
    where ',' || :para || ',' like '%,'|| sid || ',%' ;
  • concatenate the strings from a column into a single row?

    How to concatenate strings from a column into a single line?


    And return a set of results as follows:

    Red, orange, blue, green

    Various ways can be found here:

  • Concatenate the strings of several lines into one line.


    What is the name of this analytical function (or log in) which
    would return more line as a concatenated line strings. that is to say:
    (I know that it is possible using the regular functions of pipeline).
    ROW1:   STR1
    ROW2:   STR2
    ROW3:   STR3
    select tadah().... from ...
    ROW1: STR1 STR2 STR3
    Thank you.


    DanielD wrote:

    What is the name of this analytical function (or log in) which
    would return more line as a concatenated line strings. that is to say:
    (I know that it is possible using the regular functions of pipeline).

    ROW1:   STR1
    ROW2:   STR2
    ROW3:   STR3
    select tadah().... from ...
    ROW1: STR1 STR2 STR3

    The function is SYS_CONNECT_BY_PATH

  • Concatenate the strings!

    Hi all

    I do this select statement and the result is as follows:

    SQL > select 'create table ' | nom_partition | ' in select * from '. table_name | ';' from dba_tab_partitions where table_name = 'MONEY ';

    create the table P_TAB_MONEY_200908 select * money;
    create the table P_TAB_MONEY_200909 select * money;

    But I would like the return of result without P_TAB_

    Thank you!
    select 'create table ' || substr(partition_name,7) || ' as select * from ' || table_name ||';' from dba_tab_partitions where table_name='MONEY';


  • concatenate the strings in a dimension

    Hi, experts, if the data is stored as below in db.

    Time (DateTime) event (varchar2)
    2010-01-13 13:00 lunch
    2010-01-13 15:00 session
    2010-01-14 12:00 lunch
    2010-01-14 16:00 meeting
    2010-01-18 11:00 meeting
    2010-01-18 14:00 meeting

    How to display the data in the PivotTable view calendar


    S M T W T F S
    lunch lunch
    Meeting meeting

    Thank you very much!

    Hi, try this...

    Date1 select column (which has timestamp), date2 column (which has no timestamp), the week number of the date in the year (which displays the data from 1 to 52 weeks), event, the name of the day.

    Now go to Pivot, keep the week number and date1 partly lines, part, Date2 and day probation measures are partly lables measure...
    You must define an aggregation max or min for the event rule. Here, I guess I got the timestamp column, during the hours mentioned (examples of data provided by you) that one event will be there...

    Hide column Date1 pivot.

    Instead of the Date 1 column, you can take a column that got values such as: 12 AM, 01:00, 02:00,... 23:00 (must be in the same order how day begins and ends)

    I have not check cela, but assume it will work...

  • Incorporate the binary string in the string spreadsheet file

    Hello LabVIEW wizards...

    So I use scripture to VI file spreadsheet to create a beautiful layout, tabs-delimited report of one of my programs for the acquisition of data file. In one of the cells in the resulting worksheet file that I want to put a binary string of all my control values so when you open the data file all the control parameters used for its manufacture are restored, but the string is hidden when the report is displayed in Excel.

    The problem is that the binary string flattened uses tabs and returns as part of its syntax the Spreadsheet File this VI to Write it's going in all directions. Worse yet, I can't unflatten chain when I open the file text because of "corrupt data or unexpected".

    If I concatenate the string flattened with quotes around it she is superb and is placed in a single cell in Excel, but when I open the file in LabVIEW that she is still several elements in the array. I've isolated the binary string using the file VI text reading and got a subset of the quoted string, but it still unflatten correctly.

    Essentially, I need to know how to get LabVIEW to pull a string literal full of special characters into a spreadsheet file and it unflatten. Any gurus what help you can provide is greatly appreciated.

    Thank you



    I suggest that you change the formatting of your chain shipped by replacing the tabs and returns with other characters that are not considered as commands by the spreadsheet functions. Without knowing how you represent your control binary values, I can't offer specific characters.

    If two non-printable characters exist which do not appear in the control data, it's easy: just find and replace tabs and returns with those characters.  If there is no character, then something more complex needs to be done for example to escape special characters.  Or create two subVIs - one to remove the tabs and returns before writing the string in the file and the other to restore after reading.


  • concatenate the data in 2 tables in a third table as well as in CONCATENATE strings

    Hello. as the title says, I wish to only concatenate the data in 2 tables in a similar third table that concatenate strings don't. All tables should be 1 d. For example, suppose that there is 1 table with the following: 1. 2; 3; 4 and table 2 with:; b; c; d. I would like a table 3 either 1 a, 2 b, 3 c, 4 d. Now this could be done easily with above mentioned concatenate strings, then table construction. but table 1 and 2 have something like 150 items. Rather painful. Any ideas?

    Hold arrays of two strings in a loop for example, concatentate the strings inside the loop and run the result réécrirait array3.

    Autoindexing manages table manipulations.


  • Extract the contents of an XML string in offline mode

    HI gentlemen,

    Could you help me solve this problem? I had a string of Java (see below) read in a smart German eHealth card. I have to extract the tag values and put them in local variables for further processing in my Java module. How to move forward without connecting to a database, it is enough to analyze the source - the string variable? Note that the lines are separated by only 0x0A.
    <?xml version="1.0" encoding="ISO-8859-15" standalone="yes"?>
    <UC_PersoenlicheVersichertendatenXML CDM_VERSION="5.1.0" xmlns="">
    Thank you very much for your help,
    sincere friendships of

    Miklós HERBOLY
    java.lang.NoClassDefFoundError: XpathSampleClass (wrong name: XPathSampleClass)

    If you use my code sample in extenso, the class is named 'XPathSampleClass' (capital P), and of course the .class file must have the same name.

  • Concatenate and split the string

    Hi all

    Is there some how we can split the string like this "1 | ~ | Diego | Maradona | ~ | Footballer | The Argentina.

    in the table of 3 elements: '1', ' Diego | Maradona', ' football '. The Argentina.

    Here is my code
    public static void main(String args[]){
              System.out.println("========USE SPLIT========== " );
                   String data = "1 |~| Diego|Maradona |~| Footballer|Argentina";
                 String[] items = data.split(" |~| ");
                 for (String item : items)
                      System.out.println("item = " + item);
                 StringTokenizer tok = new StringTokenizer(data," |~| ");
                 System.out.println("========USE TOKENIZER========== " );
                      System.out.println("item = " + tok.nextToken());
    and put it is:
    = USE SPLIT =.
    Item = 1
    Item = |
    Item = |
    Item = Diego | Maradona
    Item = |
    Item = |
    Item = football | Argentina
    Item = 1
    Item = Diego
    Item = Maradona
    Item = footballer
    Item = Argentina

    Published by: mycoffee on February 1, 2011 06:49

    Split() takes a regular expression. ' | ' has a special meaning in regular expressions.

    Try to use

    " \\|~\\| "

    as the argument of split()

  • My indicator shows only the first line of the string

    Hi all

    I'm having some trouble with chains, could you help me?

    I use a device connected to my computer in a RS-232 port.

    I configured the VISA series correctly. When I write a command to my device, the answer is something like this:






    The problem is when I try to read this response. The channel indicator shows only one line at a time every single loop. And the other orders received are stored in the buffer until their time to be displayed to come. I mean:

    In the first loop device XXXXX responses.

    In the second loop the device responds YYYYYY but now I stored what must appear:









    In the third loop, the device responds 2222 and stores again:













    How can I configure my blocks to display the full string?

    Thank you


    Post your code and we can better understand what is happening.

    My first is however you spend only the corrent, reading of the indicator.

    You use a chain shift reg with a knot to concatenate a String?

    Your zip code and we'll have a glance.

Maybe you are looking for

  • Satellite A110-170 - upgrade to 3 or 4 GB

    Hi all I read many post about upgrading ram and have not found anything on the Satellite A110-170. Tell someone if it is possible to upgrade the computer to more than 2 GB?It's strange, Toshiba sell computers that are supposed to support up to 4 GB (

  • Recovery of the value as active and affected partition D: drive him now cannot start in os

    Don't know what I thought, was trying to find the recovery program to create dvd, so I put the recovery partition as active and assigned it D: drive now the system will not boot in OS, he goes instead to recovery mode.  Windows 7 64 Professional on e

  • my laptop msi restarts error message 0xc000000eg

    It's my son notebook, we tried a disk recovery but not good. After tring to log in the message arrives will restart in so many seconds, and any option to consider always comes back as stated above, what can we please he has exams coming

  • boring hp deskjet 1050 has black printing only? WiFi? How much ink

    After buying a printer cheap printer hp deskjet 1050a (resembling chewing itself to bits by the way), I had so much headache to install! instructions that not many of them just from the pictures! then try to find a product code to go with my serial n

  • Windows install not installed

    I went to the Forum to see if I could get an answer, but nothing helped. I tried to stop and then restart the windows installation program, did not work. have you the sfc/scan did not work. always get the "windows install not installed correctly". Wh