Output of data in one row

Hi,
I have 1000 records that are coming in a column one after the other below in different rows.
I require these records to come in a single row, with a comma after each record.
how to do this ?

"How to do this?"
Here's a step by step explanation:
Step 1: tell us your Oracle version
Step 2: Provide a CREATE TABLE statement and sample data
Step 3: someone will provide Step 3 when you have done Steps 1 and 2.

Similar Messages

  • Display array data in one row

    Hello ---
    I have an array of data, I would like to be displayed all the data in one row.<tr></tr>, how to do this?
    If I use <h:table> <column></column></h:table>, it will display different rows.
    Thanks!
    Ben

    Populate the components in the backingbean. Try something like:
    JSF<h:panelGrid binding="#{myBean.grid}" />MyBeanprivate List arrayOfData;
    private HtmlPanelGrid grid; // + getter + setter
    private void populateGrid() {
        grid = new HtmlPanelGrid();
        grid.setColumns(arrayOfData.size());
        for (Iterator iter = arrayOfData.iterator(); iter.hasNext();) {
            Object value = iter.next();
            HtmlOutputText text  = new HtmlOutputText();
            text.setValue(value);
            grid.getChildren.add(text);
    }

  • Show Column Data In One Row

    Hello,
    Tell Me how i can show a single column data in one row.
    10
    20
    30
    To
    10,20,30

    If you are OK with displaying comma separated list or column data you could:
    SQL> select  ltrim(sys_connect_by_path(ename,','),',') ename_list
      2    from  (
      3           select  ename,
      4                   row_number() over(order by 1) rn,
      5                   count(*) over() cnt
      6             from  emp
      7          )
      8    where rn = cnt
      9    start with rn = 1
    10    connect by rn = prior rn + 1
    11  /
    ENAME_LIST
    SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,MILLER,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,CLARK
    SQL> To display as separate columns you would need to either know number of rows:
    SQL> select  min(case rn when 1 then ename else null end) ename1,
      2          min(case rn when 2 then ename else null end) ename2,
      3          min(case rn when 3 then ename else null end) ename3,
      4          min(case rn when 4 then ename else null end) ename4,
      5          min(case rn when 5 then ename else null end) ename5,
      6          min(case rn when 6 then ename else null end) ename6,
      7          min(case rn when 7 then ename else null end) ename7,
      8          min(case rn when 8 then ename else null end) ename8,
      9          min(case rn when 9 then ename else null end) ename9,
    10          min(case rn when 10 then ename else null end) ename10,
    11          min(case rn when 11 then ename else null end) ename11,
    12          min(case rn when 12 then ename else null end) ename12
    13    from  (
    14           select  ename,
    15                   rownum rn
    16             from  emp
    17          )
    18  /
    ENAME1  ENAME2  ENAME3  ENAME4  ENAME5  ENAME6  ENAME7  ENAME8  ENAME9  ENAME10  ENAME11  ENAME12
    SMITH   ALLEN   WARD    JONES   MARTIN  BLAKE   CLARK   SCOTT   KING    TURNER   ADAMS    JAMES
    SQL> or use dynamic SQL.
    SY.

  • Need to split data from one row into a new row redux

    Hi folks,
    I asked this question about eight months ago (see thread https://discussions.apple.com/message/23961353#23961353) and got an excellent response from forum regular Wayne Contello.  However, I need to perform this operation again and when I attempted it recently, I am now greeted with a yellow warning triangle.  Clicking it shows "This formula can’t reference its own cell, or depend on another formula that references this cell."
    What I'm trying to do is the following:
    I have an excel file that keeps track of members of a social group.  The file places each member "unit" on a single row.  The unit can be a single person or a couple.  Columns are labeled "First1" "Last1" "Hometown1" "B-day1" while the second member of the unit is identified in columns like "First2" "Last2" etc.
    What I'd like to do is duplicate those rows with two people (which I'll do by hand) but have a way of deleting the "xxxx2" data from one row and the "xxxx1" data from the duplicate row.
    Wayne's illustrated solution was to create a blank sheet and enter the following formula in cell A2:
    =OFFSET(Input Data::$A$2, INT((ROW()−2)÷2), COLUMN()−1+IF(MOD(ROW()−2, 2)=0, 0, 4)), which apparently worked fine for me last year but now is sending up an error flag.  When I look at the formula, there is no clue except that which I quoted above.
    Can anyone (or hopefully Wayne) take a second look at this and help me out?  I can't imagine that it's a problem with using the newer version of Numbers, but who knows?  I'm using version 3.2 (1861), which is the "new" Numbers.
    Any help would really be appreciated.
    Thanks!
    -Tod

    Hi Tod,
    The error message "This formula can’t reference its own cell, or depend on another formula that references this cell." may be because your table may be different from the one you were using for Wayne's solution. Numbers has Header Rows, Footer Rows and Header Columns. Such Headers in tables exclude themselves from formulas. Excel does not recognise them as headers. What table are you using now?
    A screen shot of (the top left portion of) your table or a description of what you see under Menu > Table will help.
    Regards,
    Ian.

  • Two rows as one display the data in one row

    Hello All,
    I would like to have data of two rows put in one as:
    Lets say the data is like this:
    SELECT * FROM TEST;
          COL1       COL2       COL3 C
           1.5          3          1 M
                        2          1 C
           2.5                     2 C
                      3.5          2 M
                      4.5          3 M How do i get the output as :
           COL1       COL2       COL3 COL4 COL5
           1.5          3          1 M      2
           2.5                     2 C      3.5
                      4.5          3 M If there are two rows with same value in Col3, then col5(a new dummy column in select stmt) the second row's col2 should be disaplyed in Row 1.
    Can we do it in a Select Statement ?
    Regds,
    Amkotz

    A try :
    SQL> select * from Amkotz;
          COL1           COL2          COL3 C                                             
           1,5              3             1 M                                             
                            2             1 C                                             
           2,5                            2 C                                             
                          3,5             2 M                                             
                          4,5             3 M                                             
    SQL> select a.col1,
      2         a.col2,
      3         a.col3,
      4         a.col4,
      5         max(decode(a.rowid,b.rowid,null,b.col2)) keep (dense_rank last order by a.col1,a.col2) as col5
      6  from   (select Amkotz.*, row_number() over (partition by col3 order by col1,col2) rn from Amkotz) a, Amkotz b
      7  where  a.rn=1
      8  and    a.col3=b.col3
      9  group by a.col1,
    10         a.col2,
    11         a.col3,
    12         a.col4;
         COL1       COL2     COL3 C COL5      
          1,5          3        1 M 2         
          2,5                   2 C 3,5       
                     4,5        3 M            Nicolas.

  • Write to spreadsheet file.vi is storing data in one row only.

    The 8 points of data is going into one column in the spreadsheet. In the "Write to spreadsheet file string.vi" how do I write the 8 points to one row for each cycle?
    I got this VI from NI's web a couple of years ago and forgot how to modify this part. I usume it is within the write file.vi.
    Thank you in advance
    Skip

    I just reread your original post and the way the "Write to Spreadsheet File.vi" that ships with LV works by default is to put 1D arrays into rows. I read your post backwards and told you how to put the data in a column. Sorry.
    In any case, perhaps you need to make sure the Transpose input ISN'T true, and that the delimiter IS a tab.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How to display Column data in one row

    Hello,
    I have one Employee with 4 effective date displayed in one column. Effective date is drived by Reason of : New Hire, Rehire, Transfer etc.
    I want to show the effective dates for one reason in one single row. For example a person was rehired 4 times it will show as
    1006555     6/12/2006     1/2/2007     6/11/2007     5/12/2008     12/29/2008     5/17/2010
    It's currntly showing as:
    AUDITEFFECTIVEDATE_3
    6/12/2006
    1/2/2007
    6/11/2007
    5/12/2008
    5/17/2010

    Well that's a little tougher... For a solution to work, you're going to need to find a way to differentiate between the the specific hiring events.  Without seeing what data is available, I'd say start looking at the use of running totals... or in this case a running count.
    Set it up to reset on EmployeeID and count each "event", incrimenting up with each instance.
    Then your formula would look more like this...
    IF {EventType} = "Rehire" AND {#RTotal1} = 1 THEN AUDITEFFECTIVEDATE_3
    IF {EventType} = "Exit" AND {#RTotal1} = 1 THEN AUDITEFFECTIVEDATE_3
    IF {EventType} = "Rehire" AND {#RTotal1} = 2 THEN AUDITEFFECTIVEDATE_3
    IF {EventType} = "Exit" AND {#RTotal1} = 2 THEN AUDITEFFECTIVEDATE_3
    IF {EventType} = "Rehire" AND {#RTotal1} = 3 THEN AUDITEFFECTIVEDATE_3
    IF {EventType} = "Exit" AND {#RTotal1} = 3 THEN AUDITEFFECTIVEDATE_3
    IF {EventType} = "Rehire" AND {#RTotal1} = 4 THEN AUDITEFFECTIVEDATE_3
    IF {EventType} = "Exit" AND {#RTotal1} = 4 THEN AUDITEFFECTIVEDATE_3
    This issue then becomes an issue of space on the report. You end up wasting 1/2 of your horizontal space trying to allot for one odd ball... You'll also get to re-work the report if the same employee goes for rounds 5, 6 or 7...
    HTH,
    Jason

  • Depicting multiple rows' data in one row

    Hi All,
    Pls. check the below query:
    select manager_id mg_id, employee_id emp_id, last_name name from employees
    where manager_id = '100'
    and DEPARTMENT_ID = '80'if i run the following query, then o/p comes row wise; like below:
           mg_id           emp_id            name
           100             145                     Russell
           100             146                     Partners
           100             147                     Errazuriz
           100             148                     Cambrault
           100             149                     Zlotkeybut if i want the o/p like below; i.e; under manager # 100, all employees' emp_id and name should come in only ONE row NOT in multiple rows:
    mg_id                   emp_id     name          emp_id       name       emp_id     name         emp_id     name                emp_id         name
    100                             145             Russell     146       Partners        147     Errazuriz       148              Cambrault        149        Zlotkeypls. help me to sort out the above sought o/p.
    kindly tell me if there is any posting guidelines (except "Plain Text Help" on the right side) in this forum. i tried a lot to post above two o/p in easily readable format, but couldn't do that.
    Edited by: Shariful on Sep 20, 2009 4:28 AM
    Edited by: Shariful on Sep 20, 2009 4:29 AM

    Hi,
    Shariful wrote:
    Hi All,
    Pls. check the below query:
    select manager_id mg_id, employee_id emp_id, last_name name from employees
    where manager_id = '100'
    and DEPARTMENT_ID = '80'
    if i run the following query, then o/p comes row wise; like below:
    mg_id           emp_id            name
    100     145     Russell
    100     146     Partners
    100     147     Errazuriz
    100     148     Cambrault
    100     149     Zlotkey
    but if i want the o/p like below; i.e; under manager # 100, all employees' emp_id and name should come in only ONE row NOT in multiple rows:
    mg_id                   emp_id     name          emp_id       name       emp_id     name         emp_id     name                emp_id         name
    100     145     Russell     146     Partners     147     Errazuriz     148     Cambrault     149     ZlotkeyIf you want all the emp_ids and names concatenated into one big VARCHAR2 column, that's called String Aggregation
    [AskTom.oracle.com|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402] shows several different ways to do it.
    You can format that one big column so that it looks like separate columns.
    If you want each emp_id and name in its own column, that's called Pivoting .
    Look up "pivot" for various techniques. If you do not know exactly how many rows were in the original query (and therefore how many columns you'll need in the output), then it will require Dynamic SQL , which can be complicated.
    Unfortunately, when you do search for "pivot", mlost of the hits will be things like "Search for pivot and you'll get lots of examples".
    Re: Help for a query to add columns is one that actually has some information. It was a question very much like yours.
    kindly tell me if there is any posting guidelines (except "Plain Text Help" on the right side) in this forum. i tried a lot to post above two o/p and query in easily readable format, but couldn't do that.Type these 6 characters:
    (small letters only, inside curly brackets) before and after formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Combining data on one row of a report

    Post Author: sdgroves
    CA Forum: General
    I am trying to pull data from a Student Management System. I specifically need the data from the SMS to show up like this:
    Student Name  Student ID   English Class   History Class  Math Class
    Jones, Rick       123456       Johnson            Landers          Jones
    Right now I can get it to pull all of the data above but it brings it back on seperate rows:
    Student Name  Student ID   English Class   History Class  Math Class
    Jones, Rick       123456       Johnson           
    Jones, Rick       123456                              Landers         
    Jones, Rick       123456                                                       Jones
    Any idea on how to get it to report back all on one row?
    Thanks!

    Post Author: sdgroves
    CA Forum: General
    All of the data for the classes is coming from the same field on my report. That may be the problem. I may need to add a class period or something so it differentiates between classes?
    Thanks for your help.

  • Concatenate all data in one row to all data in the next row

    I have been trying to do this, I'm sure simple procedure, with no luck
    Table
    A B
    1 5
    2 4
    3 3
    4 2
    5 1
    and put all the data from each row into a single cell to look like this
    Table
    C
    1:5, 2:4, 3:3, 4:2, 5:1
    I imagine I need to use some kind of recursive formula but not sure how to do that in Numbers

    hoshi,
    in C, fill with: =A&":"&B
    Very simple.
    By the way, nothing recursive will work in Numbers. An error message will be generated if the result of a particular cell depends in any way upon its own content.
    Jerry

  • Need a report column to hold data for one row only

    Hey Guys,
    I have a report which has a column that links to another page in my APEX application.
    There is a requirement where only one of the rows in this report needs to have a link so I need the column to show the page link for one row and one row only.
    The report will have about 5 rows at a time so is there a way to just make this link appear for the one row(it will be the top row) in the column attirbute in APEX? or can this be done in the SQL for the report?
    Any help is much appreciated
    Thanks
    -Mark

    Hi
    The only way (I believe) to do this is within the SQL. Then you just wrap the column in a CASE statement and if it meets your criteria then build up the link and if not then display normally.
    Something like this...
    SELECT ename,
           CASE WHEN empno = 7839
           THEN '<a href="f?p='||:APP_ID||':4:'||:APP_SESSION||'::NO::P4_TARGET_ITEM:'||empno||'" >'||empno||'</a>'
           ELSE TO_CHAR(empno)
           END empno
    FROM empCheers
    Ben

  • View data in one row

    Hi, guys I have a table filled in this way and I can't modify the data inside:
    F1 F2 F3 F4
    1 A null null
    1 null B null
    1 null null C
    2 D null null
    2 null E null
    2 null null F
    3 G null null
    3 null H null
    3 null null I
    Is there a way to see the data in this other way (without any NULL)?:
    F1F2F3F4
    1 A B C     
    2 D E F
    3 G H I
    Thank you
    Alex
    Message was edited by:
    user566533
    Message was edited by:
    user566533

    > About the Model clause, I am sure Rob can do better and I am waiting for his solution ;-)
    This looks way too complex for the type of question for me. And as said you are generating more rows than necessary that have to be filtered by a subquery in the final step.
    Although I'm convinced that the original poster does not have rows with data in more than one of the columns, I could not resist the challenge and came up with this:
    SQL> create table mytable
      2  as
      3  select 1 f1, 'A' f2, null f3, null f4 from dual union all
      4  select 1, 'B', null, null from dual union all
      5  select 1, null, 'C', null from dual union all
      6  select 1, null, 'D', null from dual union all
      7  select 1, null, 'E', null from dual union all
      8  select 1, null, null, 'F' from dual union all
      9  select 2, 'G', null, null from dual union all
    10  select 2, 'I', null, null from dual union all
    11  select 2, 'H', null, null from dual union all
    12  select 2, null, 'T', null from dual union all
    13  select 2, null, 'K', null from dual union all
    14  select 2, 'U', null, 'J' from dual
    15  /
    Tabel is aangemaakt.
    SQL> select f1
      2       , max(decode(l,2,f)) f2
      3       , max(decode(l,3,f)) f3
      4       , max(decode(l,4,f)) f4
      5    from ( select t.*
      6                , row_number() over (partition by f1, l order by f) rn
      7             from ( select f1
      8                         , l
      9                         , decode(l,2,f2,3,f3,4,f4) f
    10                      from mytable
    11                         , (select 2 l from dual union all select 3 from dual union all select 4 from dual)
    12                  ) t
    13            where f is not null
    14         )
    15   group by f1
    16       , rn
    17   order by f1
    18       , rn
    19  /
       F1 F2    F3    F4
        1 A     C     F
        1 B     D
        1       E
        2 G     K     J
        2 H     T
        2 I
        2 U
    7 rijen zijn geselecteerd.which I think looks easier.
    > Is there a way to delete rows in model other than using subquery?
    Not really. You can leverage the "RETURN UPDATED ROWS" clause to not return the original rows, in other words: delete the original rows from the result set. But generating extra cells that are to be deleted later on, generally does not make much sense and (therefore?) there is no way to delete rows in the model clause. So the subquery is the way to do it if you really want to.
    Note that I use the subquery technique too for string aggregation using the model clause, because I tested the subquery filter is more performant than the RETURN UPDATED ROWS clause.
    Regards,
    Rob.

  • Displaying data in one row for  for 2 tables without relaiton

    I Have 2 tables without any relation and there is a common field and i want to display data like below
    table refdet
    1)
    refdt----------refbr----refamt----refcat
    10-aug-09---10-----34234-----101a
    10-aug-009--11----23245-----102a
    1-AUG-09----10----455.98----104A
    19-aug-09-12-----10000-------103B
    2) brdet
    trdt---------brn-----brtot-----------brcat
    11-aug09--10-----454000-------A
    09-aug-09-12-----550000-------B
    30-sep-09--10-----430000------A
    09-aug-09-11-----550000-------B
    i want to display data for each branch refdet.refbr = brdet.brn
    refdet
    Br10
    refdt----------refbr----refamt----refcat-----trdt---------brn-----brtot-----------brcat
    10-aug-09---10-----34234-----101a-------11-aug09--10-----454000-------A
    1-AUG-09----10----455.98----104A------30-sep-09--10-----430000------A
    Br 11
    10-aug-009--11----23245-----102a -------09-aug-09-11-----550000-------B
    Br12
    19-aug-09-12-----10000-------103B------09-aug-09----12-----550000-------B
    i tried the following query but its not working
    select distinct null as refdt,null as refbr,null as refamt,null as refcat,b.trdt,b.brn,b.brtot,b.brcat
    from brdet a,refdet b
    where a.refbr (+) = b.brn
    union all
    select distinct a.refdt,a.refbr,a.refamt,a.refcat,null as trdt,null as brn,null as brtot,null as brcat
    from brdet a,refdet b
    where a.refbr = b.brn (+)
    its not giving the records on each row for both side its creating separte rows for each records in both table.
    rgds
    jytohi
    -

    Hi jytohi,
    Please lean back for a moment and study your question. Ask yourself, is this a reasonable way to ask a question?
    Jopefully you'll reach the answer, "No it isn't, I need to.."
    1. Turn these
    1)
    refdt----------refbr----refamt----refcat
    2) brdet
    trdt---------brn-----brtot-----------brcatinto CREATE TABLE statements.
    2. Turn these
    10-aug-09---10-----34234-----101a
    10-aug-009--11----23245-----102a
    1-AUG-09----10----455.98----104A
    19-aug-09-12-----10000-------103B
    11-aug09--10-----454000-------A
    09-aug-09-12-----550000-------B
    30-sep-09--10-----430000------A
    09-aug-09-11-----550000-------Binto INSERT INTO statements
    3. Turn this
    refdet
    Br10
    refdt----------refbr----refamt----refcat-----trdt---------brn-----brtot-----------brcat
    10-aug-09---10-----34234-----101a-------11-aug09--10-----454000-------A
    1-AUG-09----10----455.98----104A------30-sep-09--10-----430000------A
    Br 11
    10-aug-009--11----23245-----102a -------09-aug-09-11-----550000-------B
    Br12
    19-aug-09-12-----10000-------103B------09-aug-09----12-----550000-------Binto properly formatted expected output, along with a reasonable explanation of why
    4. Turn this
    select distinct null as refdt,null as refbr,null as refamt,null as refcat,b.trdt,b.brn,b.brtot,b.brcat
    from brdet a,refdet b
    where a.refbr (+) = b.brn
    union all
    select distinct a.refdt,a.refbr,a.refamt,a.refcat,null as trdt,null as brn,null as brtot,null as brcat
    from brdet a,refdet b
    where a.refbr = b.brn (+)into a properly formatted query
    And last, put everything in into curly brackets {noformat}{noformat} to preserve formatting and blank space.
    Best regards
    Peter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Select statement problem. how to get data in one row

    SELECT
    razm.datum_sklenitve,
    razm.datum_prenehanja,
    FROM
    zket_zaposlenci zap,
    zket_delovna_razmerja razm,
    zket_delovne_razporeditve razp,
    zket_sistemizacije_dm sistdm,
    zket_organizacijske_enote oe,
    zket_delovna_mesta delm
    WHERE
    zap.iid_zaposlenca = razm.iid_zaposlenca and
    razm.iid_delovno_razmerje = razp.iid_delovno_razmerje and
    sistdm.iid_sistemizacija_dm(+) = razp.iid_sistemizacija_dm and
    nvl(sistdm.iid_organizacijske_enote, razp.iid_organizacijske_enote) = oe.iid_organizacijske_enote and
    sistdm.iid_delovno_mesto = delm.iid_delovno_mesto and
    razm.datum_sklenitve <= to_date('31.12.'||:v_datum, 'dd.mm.yyyy') and
    nvl(razm.datum_prenehanja, to_date('31.12.'||:v_datum, 'dd.mm.yyyy')) >= to_date('01.01.'||:v_datum, 'dd.mm.yyyy') and
    razp.datum_nastopa_dela <= to_date('31.12.'||:v_datum, 'dd.mm.yyyy') and
    nvl(razp.datum_prenehanja_dela, to_date('31.12.'||:v_datum, 'dd.mm.yyyy')) >= to_date('01.01.'||:v_datum, 'dd.mm.yyyy') and
    zkep_splosno.zkep_hierarh_oe_n(nvl(sistdm.iid_organizacijske_enote, razp.iid_organizacijske_enote), :v_oe, to_date('31.12.'||:v_datum, 'dd.mm.yyyy')) = 1 and
    to_char(zkep_splosno.zkep_vrni_prvi_dr(razm.iid_delovno_razmerje, to_date('31.12.'||:v_datum, 'dd.mm.yyyy')), 'yyyy') = :v_datum
    and zap.iid_zaposlenca = 1093507
    order by razm.datum_sklenitve DESC
    return this rows:
    datum_sklenitve     datum_prenehanja
    1: 01.10.2010 00:00:00 | 31.12.2010 00:00:00
    2: 01.10.2010 00:00:00 | 31.12.2010 00:00:00
    3: 01.04.2010 00:00:00     | 31.08.2010 00:00:00
    4: 01.02.2010 00:00:00     | 31.02.2010 00:00:00
    how can i get in one select just this result.
    1: : 01.10.2010 00:00:00 | 31.08.2010 00:00:00 (first of A and then the next one of B which is not the same as top of B)
    I try everything but i do not know how. If anyone know how to do this.
    regards,
    MB

    Simma wrote:
    But the above is not documented.Not only that, but it's string aggregation which isn't meeting the OP's requirements.
    Though you could be easily forgiven as the OP hasn't clearly stated the logic behind the requirements.
    It could be something like wrapping the original SQL with something like the following...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select date '2010-10-01' as ds, date '2010-12-31' as dp from dual union all
      2             select date '2010-10-01', date '2010-12-31' from dual union all
      3             select date '2010-04-01', date '2010-08-31' from dual union all
      4             select date '2010-02-01', date '2010-02-28' from dual)
      5  --
      6  -- END OF TEST DATA
      7  --
      8  select max(case when rn = 1 then ds else null end) as ds
      9        ,max(case when rn = 2 then dp else null end) as dp
    10  from (
    11        select ds, dp, row_number() over (order by ds desc nulls last) rn
    12        from (
    13              select case when lag(ds) over (order by ds desc) = ds and lag(dp) over (order by ds desc) = dp then null else ds end as ds
    14                    ,case when lag(ds) over (order by ds desc) = ds and lag(dp) over (order by ds desc) = dp then null else dp end as dp
    15              from t
    16              order by t.ds
    17             )
    18*      )
    SQL> /
    DS                  DP
    01/10/2010 00:00:00 31/08/2010 00:00:00
    SQL>but who knows?

  • Splitting data in one row and inserting into seperate rows into a new table

    i have a table table1 like the following
    column1     column2          column3
    a     b,cbdm,d     hj
    ba     hello          man
    i have to insert data from this table to table2 in the following format
    Column1          column2          column3
    a          b          hj
    a          cbdm          hj
    a          d          hj
    ba          hello          man
    It is like if data in column2 is seperated by comma i have to insert it into each sperate row
    I have to write a single procedure which will do the above. Please,Please help me
    I am very new to SQL

    I am absolutely agreeing with Billy.
    But I think u will be able to learn a lot if u try to understand the following code
    sql>select * from t1;
         C1 C2 C3
         a  b,cdbm,d  hj 
         ba  hello  man 
         x  aa,d,df  yy 
    sql>select * from t2;
         no rows selected
    sql>insert into t2
          select col1,col2,col3
         from (
         select t1.c1 col1,t1.c2 col4,t1.c3 col3,
         substr(t1.c2,
                  case n when 1 then 1 else instr(t1.c2,',',1,n-1)+1 end,
                       (case instr(t1.c2,',',1,n) when 0 then length(t1.c2)+1 else instr(t1.c2,',',1,n) end) -
                      (case n when 1 then 1 else instr(t1.c2,',',1,n-1)+1 end)) col2,n
           from t1,(select c1,c2,c3,
                              row_number() over(partition by c1,c2,c3 order by c1) n
                      from t1 connect by level <=
                                                   (length(t1.c2)-length(replace(t1.c2,',','')))) t2
           where t1.c1 = t2.c1)
         where not(n != 1 and col4=col2);
    sql>select * from t2;
          C1 C2 C3
          a  b  hj 
          a  cdbm  hj 
          a  d  hj 
          ba  hello  man 
          x  aa  yy 
          x  d  yy 
          x  df  yy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for