Split the data

Hi all

The Oracle worm: 10 gr 2.
Requriment is from the below query am getting the output as below, 

_*Query*_

with dates
as
(select to_date('2005 05', 'YYYY MM') start_date, to_date('2006 07', 'YYYY MM') end_date 
 from dual)
select substr(max(sys_connect_by_path(to_char(ADD_MONTHS(start_date, level - 1),'YYYY MM'),',')),2)
from dates
connect by ADD_MONTHS(start_date,level) <= end_date

_*Output*_

2005 05,2005 06,2005 07,2005 08,2005 09,2005 10,2005 11,2005 12,2006 01,2006 02,2006 03,2006 04,2006 05,2006 06

But is there any way that i can split the output as below 

_*Expected Output*_

2005 05,
2005 06,
2005 07,
.....
....
...
2006 05,
2006 06

Iam trying with decode, level and connect by level but the query is wrong hoping am making some logic issues. Can someone
help me out to get the desired output. Thanks in advance.
WITH t AS
     (SELECT '2005 05,2005 06,2005 07,2005 08,2005 09,2005 10,2005 11,2005 12,2006 01,2006 02,2006 03,2006 04,2006 05,2006 06'
                                                                          col
        FROM DUAL)
SELECT     LEVEL, LENGTH (REGEXP_REPLACE (col, '[^,]')),
           LTRIM (REGEXP_SUBSTR (col, '[^,]+', 1, LEVEL), ',')
      FROM t
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (col, '[^,]'))

From your query:

SELECT     LEVEL, LENGTH (REGEXP_REPLACE (col, '[^,]')),
           LTRIM (REGEXP_SUBSTR (col, '[^,]+', 1, LEVEL), ',')
      FROM (
WITH dates AS
     (SELECT TO_DATE ('2005 05', 'YYYY MM') start_date,
             TO_DATE ('2006 07', 'YYYY MM') end_date
        FROM DUAL)
SELECT     SUBSTR
                (MAX (SYS_CONNECT_BY_PATH (TO_CHAR (ADD_MONTHS (start_date,
                                                                LEVEL - 1
                                                               ),
                                                    'YYYY MM'
                                                   ),
                                           ','
                                          )
                     ),
                 2
                ) col
      FROM dates
CONNECT BY ADD_MONTHS (start_date, LEVEL) <= end_date)
CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE (col, '[^,]'))

Published by: user2361373 on Sep 8, 2011 06:36

Tags: Database

Similar Questions

  • split the data belonging to the same group at two different levels

    Hello

    I have data in the same group I want to split into two levels.

    For example: If the XML is:

    < data >
    Taxable < Type > < / type >
    < value1 > one < / value1 >
    b < value2 > < / value2 >
    < / data >
    < data >
    Taxable < Type > < / type >
    e < value1 > < / 1 >
    f < value2 > < / value2 >
    < / data >
    < data >
    Taxable < Type > < / type >
    g < value1 > < / 1 >
    h < value2 > < / value2 >
    < / data >
    < data >
    Taxable < Type > < / type >
    u < value1 > < / 1 >
    v < value2 > < / value2 >
    < / data >
    < data >
    Taxable < Type > < / type >
    o < value1 > < / 1 >
    < value2 > x < / value2 >
    < / data >


    The output using the RTF model should be:

    Taxable
    a and b
    e f
    g h

    Not taxable
    u v
    l x

    I can't change the query to add a group.

    Kindly, if anyone can help

    Published by: user10606061 on 25/06/2012 01:05


    delete a table with 2 columns and two rows. In the second column of row 1

    in column 2

    table below

    PS: your must be within a root element

  • split the data on each colon

    Hello

    I have some data in a column in my table, it is stored as 1:2:3. When I have this query with the following query:

    SELECT
    'SRR_SERVICES '. "" SHR_ID_FROM ".
    Of
    'SRR_SERVICES '.

    The output will be:

    SHR_ID_FROM
    1:2:3

    I have woul like the output to be:

    SHR_ID_FROM
    1
    2
    3

    How can I achieve this?

    For example in 10g using settlers...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select regexp_substr('1:2:3','[0-9]+',1,level) vals from dual
      2* connect by level<=length(regexp_replace('1:2:3','[^:]'))+1
    SQL> /
    
    VALS
    -----
    1
    2
    3
    
    SQL>
    
  • Distribute the data in a column and update new column with data of split

    Hi all

    I'm working on Oracle 10 g. One of my table of the column stores the data, sampled below.

    1722999340KK000200000
    1444210829AB1001EX003
    1444300000CD0148EX003
    1722999340KL 000200000

    I want to split the data in the report between the numbers (4; 6; 6; 5), as shown below and store it in different columns (A1 |) A2 | A3 | A4).
    1444 | 210829 | AB1001 | EX003

    Grateful if someone can give me some advice on how to achieve the same in the SQL database.

    See you soon,.

    novice
    insert into split_tab  (A1,A2,A3,A4)
    select substr(mycolumn,1,4), substr(mycolumn,5,6), substr(mycolumn,11,6), substr(mycolumn,17)
    from myoriginaltab;
    

    Max

  • Query SQL to split the lines based on the amount

    I have the data in the following format in the table.

    ORDER_ID PRODUCT_ID QUANTITY

    O1 A1   3

    I need to write the sql query to divide the data in following format:

    ORDER_ID PRODUCT_ID QUANTITY

    O1 A1   1

    O1 A1   1

    O1 A1   1

    Query must split the data based on the value in the quantity column.

    Thank you

    Developer

    Hello

    create table order_items (
      order_id varchar2(2),
      product_id varchar2(2),
      quantity number
    )
    ;
    insert into order_items values ('O1', 'A1', 3)
    ;
    -- Recursive Subquery Factoring
    with item(order_id, product_id, quantity) as (
      select
        order_id, product_id, quantity
      from order_items
      union all
      select
        order_id, product_id, quantity - 1
      from item
      where quantity > 1
    )
    select
      order_id, product_id, 1 quantity
    from item
    order by order_id
    ;
    drop table order_items purge
    ;
    
    Table ORDER_ITEMS created.
    
    1 row inserted.
    
    OR PR   QUANTITY
    -- -- ----------
    O1 A1          1
    O1 A1          1
    O1 A1          1
    
    Table ORDER_ITEMS dropped.
    
  • How to split the PHONE NUMBER in the column of database?

    Hello - how to split the telephone within the same column number?

    Existing column PHONE data

    3711943

    8744723

    8487928

    3349262

    I want to split the data in the same

    371-1943

    874-4723

    etc...


    Is this possible? I need to do this only through SQL query not PL/SQL.



    SUBSTR (your_col, 1, 3). » -'|| SUBSTR(your_col,4)

  • How to divide the data in the column based identifier

    Hello

    I use the oracle database.
    I have data in this format in my column 1234 ~ 2345 ~ 3456 ~ 4567.

    I need a motion to split the data in the column based on the identifier ' ~', so that I can choose the value after the second occurrence of the identifier.


    Do I know who can do this.

    Published by: 962987 on October 3, 2012 12:11

    Hello

    Welcome to the forum!

    Whenever you have any questions, please post CREATE TABLE and INSERT statements for some examples of data and the results desired from these data. For example, in view of these data

    CREATE TABLE     table_x
    (       my_column     VARCHAR2 (40)
    );
    
    INSERT INTO table_x (my_column) VALUES ('1234~2345~3456~4567');
    INSERT INTO table_x (my_column) VALUES ('just~2 parts');
    

    I think you're asking for these results

    PART_3     MY_COLUMN
    ---------- ----------------------------------------
    3456       1234~2345~3456~4567
               just~2 parts
    

    I suppose that, if the string does not contain at least 2 ' ~ s, you want to return null. It's a good idea to explain what you want like that for special cases and include examples in your sample data and results.

    Not all versions of Oracle are exactly the same. In fact, they are all different. If you want the best solution that works with your version, then say what version it is.
    The following query will work in Oracle 10.1 and higher:

    SELECT  REGEXP_SUBSTR ( my_column
                    , '[^~]+'
                    , 1
                    , 3     -- 3rd occurrence (after 2nd delimiter)
                    )     AS part_3
    ,     my_column          -- if wanted
    FROM    table_x
    ;
    

    See the FAQ forum {message identifier: = 9360002}

    Published by: Frank Kulash, October 3, 2012 15:24
    Adding sample data and results.

  • Is this ok to change the date of a photograph to the 1800s?

    I think I need to change the dates on about 400 pictures.  Enter a return date in the 1800s would cause a problem with the computer?

    This part of my family history project, which I had completely organized events in iPhoto, Photo is now a bunch of totally random photos.  They were initially examined in groups as I found them over a period of years - so in Moments - a big mess.  I had them in events either by individual or their own cell family, and of course I could merge or add however that I had to.

    Don't know yet, but I think that my best option now is to modify the dates first, just to try and get some semblance of order to it, then try to work out a system with Albums.

    Thank you

    Lynne

    I used "Set Date & Time" to put back the date of the year 1000, with no ill effects.

    I did to split times - it is very convenient to separate them all just by moving a few photos in time by 1000 years. So to adjust the dates for 200 years should be no problem.

    To adjust the dates of sins, I use this script: see this tip to user: Script: batch change Date and time on a fixed Date

    https://discussions.Apple.com/docs/doc-8421

    This script allows you to set the date and time of the selected photos to a fixed date, incremented a constant interval, for example a minute. I use it, if I don't know the exact date and time, but I just don't want the time, so photos can be sorted by time.

  • split the signal not showing multiple output

    I'm dividing the multichannel signal from acquisition of data NOR-6008. When I connect the data to the separation of the vi signal, there is that a single output eventhough I did the dow to give me all the outputs.

    Please help its urgent.

    What version of LabVIEW are you using?  You can post your VI?

    If I remember, one of the versions of LabVIEW had a bug in how the signal split function would work.

  • How the data displayed parced

    OK, Im having a bit of trouble getting the data to display in labview. I like to read from a string of succession of data which is delimeted with «,» It works fine and I can get out to the token stringn. After 7 "blocks" of data, it will start to repeat themselves. How can I get that it displays each of these 7 chuncks of data, then on the next loop them refersh.

    That's all I have for now

    If I understand the problem, you have a string that has a number of embedded commas, and you want an array of strings corresponding to the 'things' between each comma.  Your reference to 7 'chunks' might suggest that each VISA read will return a string of the form x 1, x 2, x 3, x 4, x 5, x 6, x 7 (7 points, commas 6), but this solution does not how 'chunks', just that they are separated by commas.

    It uses regular expression matching function, with the comma as the regular Expression.  This VI basically splits the string into two parts, everything before the comma (the upper exit, highlighted as an element of array) and everything (number less than forecasts, put on a shift made through new register).  Each time through the while loop pull on another element, by adding to the matrix.  When nothing is left, the loop stops.

    Examine the three odd cases - string with no comma (get a table of 1 item with the full, correct string), string starting with a comma (get an array whose first element is an empty string, correct), string 1 element, ending (or not) with a comma (get a table to correct 1 item).

    Enjoy.

    BS

  • Cannot change the date or time.

    I go to control panel or click on the time in the lower right corner, and then click change date/time.  I then click on the month (September) and scroll down to July and click on apply.  It remains July for a split second, then changes again in September.  It's the same for the day, month, and time.  Help!

    Hello

    · Were there any changes made on the computer before the show?

    · What is the edition of windows that is installed on the computer?

    · Who is the service pack installed?

    1. you can follow the steps from the link below: you can not set the date, time, or time zone on your computer: http://support.microsoft.com/kb/300022

    2. online virus scanner and check if any malware or virus detected on the computer activity. You can run the scan for viruses online from the link below: http://www.microsoft.com/security/scanner/en-us/default.aspx

    NOTE: Make sure that you select the correct version of the operating system before downloading the scanner)

  • Splitting the system partition?

    Hello

    I have two physical hard drives. Currently, each disk has a basic partition. The first detected disk has the C partition and the second disc has the partition (E) Windows XP is installed on E.

    I want to divide the C partition into two partitions. As far as I know, I have to delete the C partition and make two new partitions. I have all the data in c supported partition E if this isn't the problem. When I opened the disk management software, I realized the C partition is marked as a system partition and I can't remove it.

    Is there a way I can split this system partition?

    Hello

    I have two physical hard drives. Currently, each disk has a basic partition. The first detected disk has the C partition and the second disc has the partition (E) Windows XP is installed on E.

    I want to divide the C partition into two partitions. As far as I know, I have to delete the C partition and make two new partitions. I have all the data in c supported partition E if this isn't the problem. When I opened the disk management software, I realized the C partition is marked as a system partition and I can't remove it.

    Is there a way I can split this system partition?

    You need third party software. There are several choices, such as Partition Magic.

  • I have great meda database on excel and want to display the data comparitable on media player

    I LIKE TO "UPSIDE DOWN SCREEN" BETWEEN MEDIA PLAYER AND EXCEL DATABASE

    I have great meda database on excel and want to display the data comparitable on media player

    See: http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/split-screen-option-windows-7/369d5ef8-379a-4701-891f-04af477f5cc5

  • Analyzing the data of a column of data loading rule

    A certain column in the data file contains the following information...

    800-67-40020

    I want to load 67 just.

    How do you setup of data would load file to scan 67?

    Thank you!

    Yes *.

    For fields of nnn-nn-nnnn, you must split the field. See:

    By using a rules file to perform operations on files, fields and data

    Splitting fields

    You must create two rules and use criteria to selection/reject to reject a recordset and accept each other. See:

    Record selection

    Rejecting Records

    * Technically, the best answer is "no, avoid using rules of loading for the ETL and download the file in the right format with a more appropriate tool.

  • 0 blocks free PTR - cannot create new files on the data store

    We have been experiencing problems trying to power on virtual machines. When attempting to power on virtual machines, we see the error "cannot extend the pagefile from 0 KB to 2097152 KB".

    We checked the .vswp file are created in the folder of the Virtual Machine on the data store. Connection to the ESXi host, we have seen the following in vmkernel.log error message:

    (2016 01-16 T 21: 19:40.556Z cpu1:4971732) WARNING: Res3: 6984: "freenas-6-ds": [rt 3] No. Space - has not found enough resources after the second pass! (requis_:_1,_trouvé_:_0) 2016-01 - 16 T 21: 19:40.556Z cpu1:4971732) Res3: 6985: "freenas-6-ds": [rt 3] resources t 0, e 0, PN 16, BM 0, b 0, RCs u 0, i 0, 4031 nf, pe 0, 0 2016-01-16 T 21 oe: 19:40.556Z cpu1:4971732) WARNING: SwapExtend: 683: impossible to extend the pagefile from 0 KB to 2097152 KB.

    This was surprising given that we have about 14 TB of space available on the data store:

    [root@clueless:~] df h

    Size of filesystem used available use % mounted on

    VMFS-5 20.0 T 5.4 T 14.6 T/vmfs/volumes/freenas-six-ds 27%

    However, when we use "dd" to write a 20 GB file, we would get "no space left on device:

    [root@clueless:/vmfs/volumes/55a00d31-3dc0f02c-9803-025056000040/deleteme] dd if = / dev/urandom of = deleteme bs = 1024 count = 2024000

    DD: writing "deleteme": no space is available on the device

    263734 + 0 records in

    out 263733 + 0 reviews

    [root@clueless:/vmfs/volumes/55a00d31-3dc0f02c-9803-025056000040/deleteme] ls - lh deleteme

    -rw - r - r - 1 root root 19 Jan 255,1 M 01:02 deleteme

    We checked that we have free inodes:

    The ramdisk name system include in reserved Coredumps used Maximum reserved free use pic free maximum allocated Inodes used Inodes Inodes Mount Point

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

    root of true true 32768 KiB 32768 KiB KiB KiB 99% 99% 9472 4096 3575 176 176.

    true true etc 28672 KiB 28672 KiB 284 KiB 320 KiB 99% 99% 4096 1024 516/etc

    Choose true true 0 KiB KiB 0 KiB KiB 0 100% 0% 8 1024 8192 32768 / opt

    var true true 5120 KiB 49152 484 516 99% 90% 8192 384 379 KiB KiB KiB / var

    tmp false false 2048 KiB 262144 KiB 20 KiB 360 KiB 99% 99% 8 256 8192/tmp

    false false hostdstats KiB 310272 KiB 3076 KiB 3076 KiB 99 0% 0% 8192 32 5/var/lib/vmware/hostd/stats


    We believe that our cause is due to have 0 free blocks of PTR:

    [root@clueless:/vmfs/volumes/55a00d31-3dc0f02c-9803-025056000040] vmkfstools Pei - v 10/vmfs/volumes/freenas-six-ds.

    System file VMFS-5, 61 extending on 1 partition.

    File system label (if applicable): freenas-six-ds

    Mode: public TTY only

    Capacity 21989964120064 (blocks of files 20971264 * 1048576), 16008529051648 (15266923 blocks) prevail, max supported size of the 69201586814976 file

    Volume creation time: Fri Jul 10 18:21:37 2015

    Files (max / free): 130000/119680

    Blocks of PTR (max / free): 64512/0

    Void / blocks (max / free): 32000/28323

    The secondary blocks of Ptr (max / free): 256/256

    Drop blocks (approve/used/approve %): 0/5704341/0

    Blocks of PTR (approve/used/approve %): 64512/0/0

    Void / blocks (approve/used/approve %): 3677/0/0

    Size of volume metadata: 911048704

    UUID: 55a00d31-3dc0f02c-9803-025056000040

    Logical unit: 55a00d30-985bb532-BOI.30-025056000040

    Partitions split (on 'lvm'):

    NAA.6589cfc0000006f3a584e7c8e67a8ddd:1

    Instant native is Capable: YES

    OBJLIB-LIB: ObjLib cleaned.

    WORKER: asyncOps = 0 maxActiveOps = 0 maxPending = 0 maxCompleted = 0

    When we turn off a virtual machine, it will release 1 block of PTR and we would be able to on another VM / create the 20 GB file using "dd". Once we reached 0 free blocks of PTR, we are unable to create new files.

    Can anyone give any suggestions on how we may be able to clear the blocks PTR? We have already tried to restart all services of management on all ESXi hosts connected.

    FreeNAS is not running on a virtual machine.

    We solved the problem by finding a lot PTR blocks have been used by many of our models of virtual machine. Remove the disk models solved the problem.

Maybe you are looking for