dates of the Oracle

I have a scenario like below


Need to compress files and also to preserve if ID moves back between two Cd


-Table Script _
create table test_1 (key_id varchar (25), varchar2 (25) cd, strt_dt date, end_dt date);

-Sample data-

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13224', to_date (17 June 02 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (April 13 04 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13224', to_date (14 April 04 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (4 April 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13224', to_date (5 April 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (31 October 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (1 November 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (26 December 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (27 December 05 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (2 January 06 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (3 January 06 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (22 May 06 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (23 May 06 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (11-SEP-06 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (12-SEP-06 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (18 June 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (19 June 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (2 July 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (3 July 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (20 August 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (21 August 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (15 October 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13224', to_date (16 October 07 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (11 February 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (12 February 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (31 March 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (1 April 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (14 April 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

Insert into TEST_1 (KEY_ID, CD, STRT_DT, END_DT) values ('AAA', ' 13205', to_date (15 April 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'), to_date (9 June 08 00:00:00 ',' DD-MON-RR HH24:MI:SS'));))

COMMIT;

Desired output:

AAA 13224 17 JUNE 02 00:00:00 OCTOBER 31 05 00:00:00

AAA 13205 1 NOVEMBER 05 00:00:00 15 OCTOBER 07 00:00:00

AAA 13224 16 OCTOBER 07 00:00:00 11 FEBRUARY 08 00:00:00

AAA 13205 12 FEBRUARY 08 00:00:00 JUNE 9 08 00:00:00

I am currently using this code but its not keeping do not.

SELECT ID, min (strt_dt) strt_dt, max end_dt, cd (end_dt)

de)

SELECT ID, cd, strt_dt, end_dt, grp,

Max (GRP) on grp_max (key_id partition, cd command by strt_dt)

(select rt.key_id, rt.cd, rt.strt_dt, rt.end_dt,

case

When (lag (rt.end_dt) over (partition by rt.key_id order, rt.strt_dt rt.cd) <>rt.strt_dt - 1).

then row_number() over (partition by rt.key_id order, rt.cd of rt.strt_dt)

end grp

test_1 RT

- and rt.end_dt > 20 - JUL - 12 00:00:00 '

-Order of rt.key_id, rt.strt_dt, rt.end_dt

Group of)) by key_id, cd command by key_id, strt_dt;

can someone help me get my desired result.

SELECT ID,

CD,

MIN (strt_dt),

Max (end_dt)

Of

(SELECT ID,

CD,

strt_dt,

end_dt,

ROWNUM - ROW_NUMBER () OVER (PARTITION BY cd ORDER BY strt_dt) AS grp

OF test_1

)

GROUP BY key_id,

CD,

GRP


Reverence: Frank Kulash

Tags: Database

Similar Questions

  • Essbase Studio impossible to 'Examining the sample data' in the Oracle DB Data Source

    E.M.P. version 11.1.2.3.500

    Oracle DB 11.2.0.4

    on Windows 2008R2

    I created a user DB ESSTBC with the following user privileges

    CREATE SESSION, CREATE TABLE, CREATE TRIGGER, CREATE TYPE, CREATE VIEW

    This is my first attempt on the Essbase Studio, so I executed the following scripts as the user ESSTBC to create the TBC tables and load the data

    tbc_create_oracle. SQL

    tbc_sampledata. SQL

    I am able to connect with ESSTBC and select the tables all loaded and made sure the data is loaded correctly

    Then in the Studio of Essbase, I created a data source, which I can list all the tables in the schema ESSTBC in 'Data Source Navigator'. I also managed to create a Minischema by joining the tables SALES, SCENARIO, and MEASURES.

    However, in "Data Source Navigator" when I select "SCENARIO", right click and select "View Sample Data", I am able to pull data from the table. that is the table with all the names of columns grid but no data. No error messages were shown in "Messages to the Console.

    Back to Developer SQL and connect the same DB as ESSTBC, I have no problem do a "SELECT * SCRIPT;" and recover all the data of the table without a problem.

    I proceed creating dimensions elements then a hierarchy of "SCENARIO". But again when I try to get a glimpse of the hierarchy has got an empty tree. Apparently, there's something wrong,

    No matter what mark on what I missed?

    Thank you very much.

    Problem solved. The cause being my stupidity ruin a access DB. I can see examples of data without changing anything in Essbase Studio after you change the DB user rights.

  • load data to the oracle database...

    Dear Sir

    I use to load data to oracle database .is there other methods to load bulk data to the database sql badr...

    Discover the outer table in Oracle Utilities

  • Record great shape data in the Oracle database

    Hi all

    I have a question as to how we store a large xml for example more than 10000 bytes in the oracle database. I tried to use varchar, but the length is limited to only 4000 bytes. Could someone let me know how to achieve this.

    Basically what I'm doing is in adobe livecycle workflow I will get the user entered data in the form as formData (xml) variable and I want to keep the same for any future reference. I need to use the same data to fill the form again in the future.

    Thanks in advance.

    Shekhar,

    I had handy MySQL, so I did it using that and attached here is a sample. For Oracle, this is mission for you as well as recovery.

    -Wasil

  • Load of LKM for data in the Oracle database

    My source and target are Oracle DB. Source table is to have 1 m + data. I'm looking for LKM that use Oracle Bulk insert utility to load this data into the target table. But I can't find such a for Oracle is database MSSQL (LKM SQL for MSSQL (Bulk)). Please tell me if there is no such LKM in the case of targets Oracle DB.

    Yes. There are.
    I think you missed this one: LKM Oracle for Oracle (DBLINK) .xml

  • Export data from the Oracle Test Manager test

    Hello

    I created a few test (req.s, tests etc.) data in my OTM. Suppose if iam resettlement OATS, how can I get the test data in the new OTM. Can I export these test data to a CSV (windows) so that I can use in important in OTM.
    Can someone help me in this topic?

    Alex, can you please?

    Thank you
    Sandeep.

    Sandeep

    I see, well, you could do a report and export all the test cases, but I think it will be a lot of your time and you would lose another users, attachments, custom projects etc. fields...

    If you need to re - install the database, the best thing to do is a back up and restore, I assume that you use the database default installed (Oracle XE), here are the instructions on how to do a back up and restore:

    http://www.Oracle.com/technology/software/products/database/XE/files/install.102/b25144/TOC.htm#BABJCFBD

    Concerning

    Alex

  • Create the flat file data from the oracle table

    d_adp_num char (10)
    d_schd_date tank (8)
    d_sched_code tank (25)
    d_pay_code char (50)
    d_mil_start char (4)
    d_mil_end char (4)
    d_duration char (5)
    d_site_code char (4)
    d_dept_id tank (6)

    Select payroll_id,
    schedule_date,
    reason_code, (sched_code)
    reason_code, (pay_code)
    start_time,
    end_time,
    total_hours,
    site_code,
    department_id
    of dept_staff
    where schedule_date between (sysdate + 1) and (sysdate + 90)


    loading data for the date range instead.
    sched_code - if 'Unavailable' reason_code = 'OD' and 'THE '.

    pay_code - "Berevevement BD" If reason_code = "BD".
    "UP PTO without reasonable excuse" If reason_code = 'UP '.
    "RG" If reason_code = "SH".
    "PTO" If reason_code = "GO".
    Here are some...

    start_time and end_time - convert military time
    based on start_ampm and end_ampm

    On this basis, I need help to create a flat file. Sewing of the flat and data file in dept_staff sample

    If site_code is there so no need to get department_id (see the sample flat file)
    ------------------------------------

    examples of data to flat file

    ZZW002324006072012 PTO
    0800160008.00
    ZZW002428106072012 RG
    1015174507.50HM34
    ZZW002391606072012 RG
    1100193008.50
    ZZW002430406072012 RG
    1100193008.50 130000
    ----------------------------

    dept_staff table data

    REASON_CODE_1 PAYROLL_ID SCHEDULE_DATE REASON_CODE START_TIME, END_TIME START_AMPM END_AMPM TOTAL_HOURS SITE_CODE DEPARTMENT_ID
    ZZW0024468 08/06/2012 HS HS 730 HAS 400 850 12 P
    ZZW0000199 08/06/2012 HS HS 730 HAS 400 850 14 P
    ZZW0023551 08/06/2012 SH SH 1145 A 930 975 GH08 95 P
    ZZW0024460 08/06/2012 SH SH 515 HAS 330 P 1025 GH08 95
    ZZW0023787 08/06/2012 SH SH 630 HAS 300 850 24 P
    ZZW0024595 08/06/2012 TR TR 730 HAS 400 850 90 P
    ZZW0023516 08/06/2012 OD OD 800 HAS 400 800 95 P
    ZZW0023784 08/06/2012 OD OD 800 HAS 400 800 5 P
    ZZW0024445 08/06/2012 SH SH 1145 A GH08 930 975 5 P
    ZZW0024525 08/06/2012 OD OD 800 HAS 400 800 23 P
    ZZW0024592 08/06/2012 TR TR 730 HAS 400 850 5 P
    ZZW0024509 08/06/2012 SH SH 95 MK21 830 HAS 330 P 700

    ZZW0023916 06/14/2012 SH SH 1100 A 850 27 730 P

    How to ask questions
    SQL and PL/SQL FAQ

    UTL_FILE allows to write the OS file

  • Date of the Oracle in unix timestamp

    Hello..

    1. What is the command to convert oracle date to unix timestamp?
    2. What is the command to convert oracle unix timestamp date?

    It's my request of conversion, but when I converted from date oracle on another server time become a late hour. Why this happened?... y at - it no problem on the configuration of my sessiontimezone or dbtimezone?

    create or replace FUNCTION oracle_to_unix
    (
    in_date IN DATE)
    RETURN NUMBER
    IS
    BEGIN
    RETURN (in_date-TO_DATE('19700101','yyyymmdd')) * 86400 - TO_NUMBER (SUBSTR (TZ_OFFSET (sessiontimezone), 1, 3)) * 3600;
    END;


    Please help me...

    Thank you
    Balleur

    Hello!

    If I subtracted something and then add the same then I should get the same result.

    I tried like this

    SQL> select sessiontimezone from dual;
    
    SESSIONTIMEZONE
    ---------------------------------------------------------------------------
    +01:00
    
    SQL> select dbtimezone from dual;
    
    DBTIME
    ------
    +02:00
    
    SQL> select (to_date('14.03.2010 08:16:22','dd.mm.yyyy HH24:mi:ss')
      2        - to_date('01.01.1970 00:00:00','dd.mm.yyyy HH24:mi:ss')) * 24 * 60 * 60
      3        - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600 utim
      4    from dual
      5  /
    
          UTIM
    ----------
    1268550982
    
    SQL> select to_char(to_date('01.01.1970 00:00:00','dd.mm.yyyy HH24:mi:ss') +
      2  (1268550982+TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone),1,3))*3600) / 24 / 60 / 60,
      3  'DD.MM.YYYY HH24:MI:SS')  from dual
      4  /
    
    TO_CHAR(TO_DATE('01
    -------------------
    14.03.2010 08:16:22
    
    SQL> 
    

    and he seems allright for me.
    Check sessiontimezone sessions on both servers. This calculation depends only on sessiontimezones.

    T

  • date of the Oracle of the chain

    I have three numbers stored in three different variable and want to join each of them to make a date to a string, although kindly help me with this.

    Published by: AMaster Sep 6, 2012 04:12

    Example:

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    v_day varchar2(2) := '17';
      3    v_month varchar2(2) := '08';
      4    v_year varchar2(4) := '2012';
      5    v_dt   date;
      6  begin
      7    v_dt := to_date(v_day||v_month||v_year,'DDMMYYYY');
      8* end;
    SQL> /
    
    PL/SQL procedure successfully completed.
    

    It takes 3 channels varchar represents the known parts of a date, assembles them together and turns this chain resulting in a data type DATE by specifying the correct format mask.

    If you want something different, we will need more information.

  • Cannot use the native sequence of database to insert data through the DbAdapter

    Hello

    I use Oracle Fusion Middleware 12.1.3 (selection of pre-designed developer programs for Oracle VM VirtualBox VMs |) Oracle Technology Network). I'm trying to insert data into the Oracle database coming with the device via a DbAdapter. I want to use the native Oracle sequences for primary keys and have configured appropriatelly the DbAdapter. But in execution, I get the following exception:

    Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ('SCOTT'. "ORDERS '." (' ' ID ')

    If I configure the such DbAdapter that do not use sequences, I get the same exception. I'm missing here?

    Kind regards

    Nicolas

    Reading more carefully the exception, in the log file of the server, not just the display of messages in the console of the em, I could note that the ConnectionFactory configured on the outgoing Dbadapter connection used to access the database was incorrect. He was using JavaDb instead of Oracle that I made a mistake of copying and pasting. Correction of this error has resolved the problem.

  • Data migration from Oracle to SQL Server

    Hello

    I have the Oracle database in one or several table, I also blob data, i.e. images are stored, now I want to move that data to the sql server database, which is the best way to do this?

    I would like to test for a migration of the table that contains the image data in the Oracle database and invade the SQL Server table.

    How to test for an Oracle table data to SQL Server migration?

    But the first thing I want to confirm is that if the Image from Oracle DB to SQL Server DB data are possible? is there something must be supported during the migration?

    Thanks in advance.

    Kind regards

    Vishal

    Published by: 968331 on October 31, 2012 02:31

    I think that it is supported. The equivalent data type in sql server is IMAGE/varbinary (max)

    See the bottom of the article for the mapping of data types:

    http://weblogs.sqlteam.com/jamesw/archive/2010/07/28/datatypes-translation-between-Oracle-and-SQL-Server-part-1.aspx

  • How to store the captured data in the csv file

    Here's the sceanario

    I was able to capture data from the oracle forms and store it in variables.
    now, I want to store the same data in the csv file and save this csv file.
    quick reply is appreciated.

    Ok. This is what my, admittedly simple, code performs above: var_orderid col1 and col2 in var_quantity.

    See you soon,.
    Jamie

  • SSRS for lack of outer join with the Oracle data source

    It seems to be a problem with the Oracle driver used in the Reporting SERVICES query designer.

    When you use an Oracle data source, if I create an outer join in the graphic designer, it automatically inserts '{OJ' before the join and '} ' after her.  This is an incorrect syntax for Oracle and refuses to start.  The curly braces and the JO editable in designer text, but if I go back to the graphic designer and immediately to reintegrate them.

    Only, this has started to happen a year or two ago - before that it worked, but with the old (+) syntax.

    Can it not be healed?  It makes things very difficult.

    -Geoff

    Hi Geoff,

    Thanks for posting in the Microsoft Community.

    However, the question you posted would be better suited in the Forums of the Oracle Support; We recommend that you post your query in Oracle Support Forums to get help:

    https://forums.Oracle.com/forums/main.jspa;JSESSIONID=8d92100c30d8fb401bcbd10b46c38c9ddf1a3242549a.e34SbxmSbNyKai0Lc3mPbhmSc3aNe0? CategoryID = 84

    If you have any other questions or you need Windows guru, do not hesitate to post your questions and we will be happy to help you.

  • How to get the column provided out of the Oracle Data Miner?

    Hi all!

    I use Oracle Data Miner provided with Oracle SQL Developer to predict the loss of customers. If I plan on the table column lets say X (as a target column) of table say T, so how can I get the corresponding values under my model?

    Here is the simplified model for the reference.

    Thanks in advance!

    Customer churn.PNG

    Hello

    Simply connect a node that accepts data to the node to apply it.

    For example, if you want to create a view or table table using the prediction of outputs generated by the node to apply it, and then add a Create Table node and connect the node to apply it.

    For more information, try the Oracle by example tutorials for ODMr.

    You must use the node apply Publisher to revise prediction outputs models to generate as well as the additional columns to include, for example columns id.

    There are a set of predictor columns added by default that may be acceptable.

    THX, mark

  • Create the data source NoSQL Oracle using Oracle Weblogic 11 g

    Hello

    I'm working on a VINE by which I want to connect NoSQL Oracle database with Oracle Weblogic11g as a new source of data in Oracle Database 11 g of accompaniment.

    So my question is that Oracle Weblogic 11 g support NoSQL Oracle database as a data source OR can I plug NoSQL Oracle database as the source of data with Oracle Weblogic11g?

    Thank you...

    Hello

    By 'data source' I assume you mean a JDBC data source. Is this fair?

    If so, please be aware that NoSQL DB does not support SQL or JDBC, although these features can be added in the future. Currently, to access data in the NoSQL database from your application, you must use the Java APIs in the pilot of the client which is included in the package. Please see the Starter Guide for more information.

    That answer your question?

    -mark

Maybe you are looking for

  • Satellite A300-1J1 - sound doesn't work only with Windows XP

    I have a problem, yesterday I installed on my Toshiba Satellite A300 1J1 WindowXP, but no sound! I tried all sound driver Toshiba on the Toshiba web site but no result!Some can help us?

  • I can't iTunes to temporarily ignore the checkboxes for playback?

    Pretty much what the title says. I uncheck some songs in my main library because I rarely, if ever play and I don't want to have to jump on them when they come to shuffle. However, recently, I wanted to listen to all the songs on a series of albums t

  • How to connect the computer to computer laptop?

    Hello world!I want to connect computer (OS windows XP prof.) with laptop (windows 7 home Premium OS) using the twisted pair. (Cross-over)Can anyone describe * step * (if possible) the settings in both systems?I tried, in vain.Computers do not see eac

  • OfficeJet J4580: Suggestions for a good scanning program:

    I would like to be able to scan multi-page documents into a single analysis.  Now, when I scan multi-page documents, the analysis translates into separate pages.  The scanner to work scanning documents with multiple pages in a single analysis, and al

  • T400 model letters

    Someone at - it clues as to what the last three letters on the Thinkpad stand for? For example, my T400 is a 7417CTO. What does the acronym for the CTO? Thank you