Grouping based on start and end of year

Hi all

Need your help to solve a SQL query

My data like this look

year of CID rid
52 1000 2001 1
52 1000 2002 1
52 1000 2003 6
52 1000 2004 6
52 1000 2005 6
52 1000 2007 1
52 1001 2003 1
52 1001 2004 1
52 1001 2005 1
52 1001 2006 3
52 1001 2007 3

I need to produce the output is

CID RID TITLE START AND END
52 1000 2001 - 2002 1
52 1000 2003 - 2005 6
52 1000 2007 - 2007 1
52 1001 2003 - 2005 1
52 1001 2006 - 2007 3
-----------
Here's the script for the table and data

create table T)
CID NUMBER,
rid the NUMBER,
start_year NUMBER,
title NUMBER
);

Insert into t (cid, RID, start_year, title) values (52, 1000, 2001, 1).
Insert into t (cid, RID, start_year, title) values (52, 1000, 2002, 1).
Insert into t (cid, RID, start_year, title) values (52, 1001, 2003, 1);
Insert into t (cid, RID, start_year, title) values (52, 1000, 2003, 6);
Insert into t (cid, RID, start_year, title) values (52, 1001, 2004, 1);
Insert into t (cid, RID, start_year, title) values (52, 1000, 2004, 6);
Insert into t (cid, RID, start_year, title) values (52, 1001, 2005, 1).
Insert into t (cid, RID, start_year, title) values (52, 1000, 2005, 6);
Insert into t (cid, RID, start_year, title) values (52, 1001, 2006, 3);
Insert into t (cid, RID, start_year, title) values (52, 1001, 2007, 3);
Insert into t (cid, RID, start_year, title) values (52, 1000, 2007, 1);

commit;

I managed to go as far (some as close to what I need but not exactly what I need)

Select the title, max (year1), min (year2), cid, RID
de)
Select tc.cid, tc.rid, tc.title, tc.start_year year1, year2, tp.start_year, decode (tc.title, tp.title, 'n', 'Y') gap
t tc,.
t tp
where tc.start_year - 1 = tp.start_year
and tc.cid = tp.cid
and tc.rid = tp.rid
)
Cid group, RID, title, gap


Thank you for thinking

Ngoyi,

Houston-Texas

Hi, Ngoyi,

Here's one way:

WITH      got_grp_id     AS
(
     SELECT     cid, rid, start_year, title
     ,     ROW_NUMBER () OVER ( PARTITION BY  cid, rid
                               ORDER BY          start_year
                       )
           -     ROW_NUMBER () OVER ( PARTITION BY  cid, rid, title
                               ORDER BY          start_year
                       )         AS grp_id
     FROM    t
)
SELECT       cid
,       rid
,       MIN (start_year) || '-'
                        || MAX (start_year)     AS start_end
,       title
FROM       got_grp_id
GROUP BY  cid, rid, title, grp_id
ORDER BY  cid, rid, start_end
;

Thanks for posting the CREATE TABLE and INSERT statements; It is very useful.
Still, it would be more useful if the sample data and the results don't always have the same value in a column. I'm just guessing at what cid and get rid of play in this problem.
Also, thanks for posting your request. It helps to understand the problem.

For an explanation of the technique of Difference sets used in the above query, see {message: id = 9953384} and/or {message: id = 9956917}

Published by: Frank Kulash, March 23, 2012 13:34

Tags: Database

Similar Questions

  • Need help to calculate the start and end time and place the result in a term like text box

    I did a search on the forum for calculating start and end time and found the code depending on which I am using as a formcalc on the duration field.
    ==============================================================
    Form1. Page1.duration::calculate - (FormCalc, client)

    If (HasValue (StartTime) and HasValue (EndTime)) then
    industrial var = Time2Num (StartTime.formattedValue, "h: mm A")
    var = Time2Num out_ (EndTime.formattedValue, "h: mm A")
    If (IN2 > = out_) then
    xfa.host.messageBox ("start time cannot be greater than or equal to the end time.")
    $.rawValue = null
    on the other
    var out_ - IN2 = diff
    $.rawValue = diff/3600000
    endif
    on the other
    $.rawValue = null
    endif
    =============================================================

    Then, when I enter for example from 15:30, an hour of beginning and end of 04:00

    The duration field will say 0.5

    How can I get my form to say 30 minutes instead of placing a decimal?

    Secondly, how can I use field models LC where the employee can just type 330 or 03:30 and it automatically based on the computer's clock on time to start 15:30?

    Any help will be greatly appreciated.  Thank you.

    Attached is the form for display:

    https://Acrobat.com/#d=f1kxh5qjuow5ujyZduF8OQ

    To view the results in a regular time format, you can use:

    $.rawValue = Num2Time (diff/3600000, "HH: mm")

    For a flexible time entry check this example.

    http://thelivecycle.blogspot.com/2011/05/flexible-Eingabe-von-Daten-und-Zeiten.html

  • Find records overlapping start and end dates

    Hi all

    I have a table with begin and end date columns. I need to find the records that overlap with a few values in corresponding column.

    Table: MG_AUTH_AGNT
    -----
    ID
    MGATH_clnt
    MGATH_beg_DT
    MGATH_END_DT
    MGATH_SERV_GRP
    MGATH_STAT
    MGATH_TYP
    MGATH_NHIC_ERR_CD
    -----
    I need to find records containing dates that overlap.

    Examples of data
    -----

    If the customer has two records with the same MGATH_SERV_GRP, MGATH_STAT, MGATH_TYP and start and end dates of the first disc are 01/JAN/2009 AND 01 / JAN / 2009.
    start and end dates of second record are 15/JAN/2009 and 15/FEB/2009.
    Here are the dates overlap. with my select query, I should get these two recordings.

    I am using the following query. But it is too slow. Could you please suggest a better sql?
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Select MG_AUTH_AGNT m, MGATH_clnt, MGATH_beg_DT, MGATH_END_DT, MGATH_NHIC_ERR_CD, id where m.MGATH_SERV_GRP = '1' and m.MGATH_STAT = 'A' and MGATH_clnt = (select distinct MGATH_clnt of MG_AUTH_AGNT d where d.MGATH_SERV_GRP = m.MGATH_SERV_GRP and d.MGATH_TYP = m.MGATH_TYP and m.MGATH_CLNT = d.MGATH_CLNT and d.MGATH_STAT = m.MGATH_STAT and m.idd.id ((trunc (m.MGATH_beg_DT) & gt; = trunc (d.MGATH_beg_DT) and trunc (m.MGATH_beg_DT) & lt;=trunc(d.MGATH_END_DT)) or (trunc (m.MGATH_END_DT) & gt; = trunc (d.MGATH_beg_DT) and trunc (m.MGATH_END_DT) & lt; = trunc (d.MGATH_END_DT)) or (trunc (m.MGATH_beg_DT) & lt; = trunc (d.MGATH_beg_DT) and trunc (m.MGATH_END_DT) & gt; = trunc (d.MGATH_END_DT))) MGATH_clnt order MGATH_beg_DT

    Published by: user10727414 on March 17, 2009 01:36

    user10727414 wrote:
    My data is correct

    MGSRV_CLNT = MGSRV_BEG_DT = MGSRV_END_DT
    501184242 = 28-AUG-07 = 31-DEC-9999
    501184242 = 28-AUG-07 = 31-DEC-9999
    501184242 = 20-DEC-07 = 31-DEC-9999
    501184242 = 20-DEC-07 = 31-DEC-9999

    And we had to guess that a year of "99" was in fact "9999" were we? Hang on I'll go and dust off my crystal ball.

    Well, now we know the correct dates (?), we'll put that in the original request...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with mypeople as
      2  (select 501184242 as id, to_date('28-AUG-2007','DD-MON-YYYY') as stdt, to_date('31-DEC-9999','DD-MON-YYYY') as endt from dual union all
      3   select 501184242, to_date('28-AUG-2007','DD-MON-YYYY'), to_date('31-DEC-9999','DD-MON-YYYY') from dual union all
      4   select 501184242, to_date('20-DEC-2007','DD-MON-YYYY'), to_date('31-DEC-9999','DD-MON-YYYY') from dual union all
      5   select 501184242, to_date('20-DEC-2007','DD-MON-YYYY'), to_date('31-DEC-9999','DD-MON-YYYY') from dual union all
      6   select 2, to_date('19/01/2009','DD/MM/YYYY'), to_date('24/01/2009','DD/MM/YYYY') from dual)
      7  -- END OF TEST DATA
      8  select id, stdt, endt
      9        ,case when lead(stdt) over (partition by id order by stdt,endt) <= endt
     10                or lag(endt) over (partition by id order by stdt,endt) >= stdt then 'Overlap'
     11              else 'Ok'
     12         end as status
     13  from mypeople
     14* order by id, stdt, endt
    SQL> /
    
            ID STDT      ENDT      STATUS
    ---------- --------- --------- -------
             2 19-JAN-09 24-JAN-09 Ok
     501184242 28-AUG-07 31-DEC-99 Overlap
     501184242 28-AUG-07 31-DEC-99 Overlap
     501184242 20-DEC-07 31-DEC-99 Overlap
     501184242 20-DEC-07 31-DEC-99 Overlap
    
    SQL>
    

    Looks like it works for me.

    If it does not work for you then maybe had better give us a statement of create table and insert to your data in the example statements then we can see what you're trying to do.

  • Since the update to firefox 10.0 (and then 10.0.1), the bottom of the Page, the Page Up keys, start and end work correctly. Is that what someone else has this problem, and are there any suggestions for a fix?

    for example, I read a Web page, when I push the bottom of the keyboard Page, sometimes nothing happens. Sometimes the page scroll a few lines but then does not continue to scroll down when I push the key several times. Sometimes the page immediately jumps to the bottom of the page; etc. Similar issues occur, in the direction towards the top, when I press the Page up key. The keys start and end are completely "dead", because the page does not move when I press them.
    It is important to note that all these keys work as usual when I open the browser Chrome or Internet Explorer, and other applications in which keys should be functional, so this problem is specific to Firefox.

    Hello

    Please check if still use the keys cursor to navigate through the pages is selected in Tools (Alt + T) > Options > Advanced > general and uncheck. This setting can also be turned on/off by pressing F7.

  • How does the index start and end in the reference Word text VI to a word document?

    How a correlation between the index values start and end to a position or coordinate in a Word document?

    Is it a type of lookup table that will refer to a value of say '35' (to start) to a line or a particular character of the position in a Word document? There is nothing in LV help which explains nothing other than the value '-1 '.

    Hey, JayB,.

    The start and end of the Text.vi in Format Word values are the positions of the characters in the document. The values start at 0 on the first (or ASCII character such as a space, tab, or carriage return) and for each character (or the ASCII character). So for example if I wanted to "BOLD" the word "carrots" in the list below, where the values start at 0 on the word 'grocery store '.

    Grocery store:

    Apples

    Black berries

    Carrots

    Detergent

    Then I would enter a start 33 and the end of the 40s, making sure to count the ramasseherbe returns and spaces.

    I hope this helps.

    Logan H

  • Can I add start and end dates to flex in WCS assets?

    Hi all

    I have to add the start and end dates to my flex belt and make it visible on the plus edition + inspect mode. For the Fund, it is STANDARD, but I have an obligation to do so for other assets that is not active promotion.

    Is there any doc/blog I can do? Help, please.

    Hi Avi.

    Dates of start and end standards are OOTB field in the metadata of the asset. So they you must set the cs.sitepreview property in the file futuretense.ini in the 'management '.

    CS.sitepreview = ContentManagement

    You can check out the documentation for more details about this property: futuretense.ini - 11 g Release 1 (11.1.1.8.0)

    If you need something different, maybe you need create your own attributes Start Date and end using types date: Data Design: active models - 11 g Release 1 (11.1.1.8.0)

    Kind regards

    Raul.

  • Photoshop CC 2015 is a line connecting the start and end of the brush strokes

    Hi guys,.

    I had a strange problem with a certain brush (size 5px, difficult tour, no shape dynamics, no transfer) in Photoshop CC 2015.1.2.

    It only happens when the drawing very fast on my Cintiq 22HD.

    The problem is PS is a line connecting the start and end of the brush strokes. I don't hold in shift or whatever it is.

    PScc_problem.jpg

    Here's my brush settings:
    Capture.JPG

    I use a PC with these specs:

    Intel Core i7 - 4790 K 4.00 GHz

    ASUS motherboard

    NVIDIA GeForce GTX 970 (10.18.13.5354 driver version)

    16 GB OF RAM

    Cintiq 22HD

    Win 10

    Is it a question of PS or Cintiq?

    Thanks for help.

    OK, here is therefore an update.

    The problem is not at all with Photoshop or Cintiq, with Windows 10 parameters of the stylus.

    Fortunately, there is a small piece of free software that you can download called "Fix my pen" (by Smith Reddy) which defines the features of Windows Tablet PC in the registry for you (essentially by disabling everything related to it):

    viziblr - News - difficulty my pen makes your Wacom tablet JUST WORK on Windows 7

    It works fine on Win10 too.

    Now, as my original problem with Photoshop to do a line connecting the start and end of the brush strokes left, however I have another question more small that came after running difficulty my pen. The lines that I draw now are not smoothed by a software more. You can see the difference below.

    Fix My Pen sets a lot of things in the registry, but you cannot individually control which setting is disabled. So I guess that one of them is the cause.

    I expect response from Smith about it, cause I have no idea who he is.

  • Primavera P6 API - start and end dates of the activity in the secondary reference scenario

    How to seek early and dates of activity in the secondary database or tertiary reference end? There are areas of activities and methods provided in planning extraction and primary base line project (active class getBaseline1StartDate(), getBaseline1FinishDate) but can't find any secondary data or tertiary basis even if we show them in details the activity in the Primavera. I use Primavera integration API version 8.2.

    Use the BaselineProjectHelper class to get a list of all the base lines for a given project.  Go through the list looking for basic lines you are interested in.

    Once you have basic interest projects, pull a list of ongoing project activities.

    Browse the list of activities tearing you start and end dates.

    Call the method on each of you loadBaselineActivity of reference projects for the departure of the referenced activity and end dates.

    For performance, seek assistance loadBaselineActivities to reduce database queries.

    V/r,

    Gene

  • Why threads start and end at random?

    Hello

    I had the program below. I wonder why mark the beginning of discussions and put an end to chance? Every time I run the program, it produces different results.

    I know these four threads have gotten the same priority normal (or 5) and under windows, there is only something called timeslice. These four threads then turn using this timeslice. How do we know what exactly the timeslice is in seconds? If the timeslice is fix, then why are the results random?

    Thanks in advance!

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package mythreadone;

    /**
    *
    Administrator of * @author
    */
    / public class MyThreadOne implements Runnable {}

    String tName;
    Thread t;

    MyThreadOne (String threadName) {}
    tNom = threadName;
    t = new Thread (this, tNom);
    t.Start ();
    }

    public void run() {}
    try {}
    System.out.println ("Thread:" + tName);
    Thread.Sleep (2000);
    } catch (InterruptedException e) {}
    System.out.println ("Exception: thread")
    tNom + "interrupted");
    }
    System.out.println ("completed thread:" + tName);
    }

    Public Shared Sub main (String [] args) {}

    Why threads start and end at random?
    new MyThreadOne("1");
    new MyThreadOne("2");
    new MyThreadOne("3");
    new MyThreadOne("4");
    try {}
    Thread.Sleep (10000);
    Thread.Sleep (2000);
    } catch (InterruptedException e) {}
    System.out.println)
    "" Exception: main Thread interrupted. ");"
    }
    System.out.println)
    "' Complete thread: main thread."); "
    }
    }


    1. first of all, I put in the main function:

    Thread.Sleep (10000);

    and I run the program it gives:

    Thread: 1
    Thread: 4
    Thread: 2
    Thread: 3
    Wire termination: 1
    Wire termination: 3
    Wire termination: 4
    Complete thread: 2
    Complete thread: main thread.
    BUILD successful (total time: 10 seconds)

    Run it again, it gives:

    Thread: 2
    Thread: 4
    Thread: 3
    Thread: 1
    Complete thread: 2
    Wire termination: 1
    Wire termination: 3
    Wire termination: 4
    Complete thread: main thread.
    BUILD successful (total time: 10 seconds)

    And my question is why it displays like this? It suppose to be:

    Thread: 1
    Thread: 2
    Thread: 3
    Thread: 4
    Wire termination: 1
    Complete thread: 2
    Wire termination: 3
    Wire termination: 4
    Complete thread: main thread.
    BUILD successful (total time: 10 seconds)

    Why these four threads begin and end at random whenever I run the program? I use Windows, assume that there is a timeslice (i.e. 1 second), these discussions have the same priority. Then the son must begin and end in turn one. Am I wrong?

    2. my second question is:

    When I change the codes of the 'main' function, in:

    Thread.Sleep (10000); -> Thread.sleep (2000);

    It gives me the results as:

    Thread: 1
    Thread: 4
    Thread: 3
    Thread: 2
    Complete thread: main thread.
    Wire termination: 1
    Wire termination: 4
    Wire termination: 3
    Complete thread: 2
    BUILD successful (total time: 2 seconds)

    Run it again:

    Thread: 1
    Thread: 2
    Thread: 3
    Thread: 4
    Wire termination: 3
    Complete thread: main thread.
    Wire termination: 4
    Complete thread: 2
    Wire termination: 1
    BUILD successful (total time: 2 seconds)

    I tried several times. The main thread always ends before or after the first child thread over.

    My question is why he didn't come out something like:

    Thread: 1
    Thread: 2
    Thread: 3
    Thread: 4
    Wire termination: 3
    Wire termination: 4
    Complete thread: 2
    Complete thread: main thread.
    Wire termination: 1
    BUILD successful (total time: 2 seconds)

    or

    Thread: 1
    Thread: 2
    Thread: 3
    Thread: 4
    Wire termination: 3
    Wire termination: 4
    Complete thread: 2
    Wire termination: 1
    Complete thread: main thread.
    BUILD successful (total time: 2 seconds)

    user13476736 wrote:
    You can specify the reason please? See you soon.

    It's pretty simple. Start-up and execution of threads are not an operation of determenistic on operating systems that do not support hard real-time requirements. (Most operating systems do not support hard real-time requirements)

  • Time of start and end elements

    Hey there,
    I have an application where I need two elements of time. I can hard code the data once and use a Select list, but this link below by Daniel McGhan is the way to go. Does anyone know how to access this code for the start and end time the elements? The article does not list how this is possible, but I can have over looked something... not sure. Thank you for reading this Thread.
    http://apex.shellprompt.net/pls/apex/f?p=566:4:198609458994020::NO:::

    Hello:

    Now sure to know how this was done, but it seems as likely javascript.

    There is a very cool JQuery Timepicker that I really like and in fact for a really nice interface:

    http://Haineault.com/Media/jQuery/UI-timepickr/page/

    Kind regards

    Bruce

  • Calculate the start and end date in Connect By - during Hirerchy changes

    / * Formatted 05/20/2013 09:53 (PS5 v5.115.810.9015) * /.



    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    Hello, can you please help me or guide me in the calculation of the dates of beginning and end to the underside of logic

    I want to calculate the Hirerchy Manager to the Agent.
    Then under query works fine and its giving me the expected results
    But when there is a change in the Hirerchy Manager or manager gets promoted
    Then I need to calculate the start date and end date.
    CREATE TABLE PERSON_DTL
    (
      SID                 VARCHAR2(10 BYTE),
      EMP_MGRS_ID         VARCHAR2(10 BYTE),
      START_EFFECTIVE_DT  DATE,
      END_EFFECTIVE_DT    DATE
    );
    
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M100', 'M107', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M101', 'M102', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('A100', 'M100', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M100', 'M101', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M107', 'M102', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M102', 'M103', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M103', 'M104', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('A101', 'M105', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M105', 'M106', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    SELECT   CONNECT_BY_ROOT (b.sid) agent_sid,
                 TRIM (
                    LEADING ',' FROM    SYS_CONNECT_BY_PATH (b.sid, ',')
                                     || ','
                                     || b.emp_mgrs_id
                 )
                    PATH,
                 START_EFFECTIVE_DT Start_dt,
                 END_EFFECTIVE_DT End_dt
          FROM   PERSON_DTL b
         WHERE   CONNECT_BY_ISLEAF = 1
    START WITH   sid IN ('A101', 'A100')
    CONNECT BY   PRIOR b.emp_mgrs_id = b.sid
    This is the results that i am getting now.
    
    AGENT_SID    PATH                       START_DT    END_DT
    
    A100    A100,M100,M101,M102,M103,M104    1/1/2010    12/31/9999
    A100    A100,M100,M107,M102,M103,M104    1/1/2010    12/31/9999
    A101    A101,M105,M106                   1/1/2010    12/31/9999
    Results Required
    
    A100    A100,M100,M101,M102,M103,M104    1/1/2010    5/18/2013
    A100    A100,M100,M107,M102,M103,M104    5/20/2013   12/31/9999
    A101    A101,M105,M106                   1/1/2010    12/31/9999

    WITH the CLAUSE will make it readable

    SQL> with paths as
      2  (
      3        SELECT   CONNECT_BY_ROOT (b.sid) agent_sid,
      4                 TRIM (
      5                    LEADING ',' FROM    SYS_CONNECT_BY_PATH (b.sid, ',')
      6                                     || ','
      7                                     || b.emp_mgrs_id
      8                 )
      9                  PATH,
     10                 START_EFFECTIVE_DT Start_dt,
     11                 END_EFFECTIVE_DT End_dt,rownum rn
     12        FROM   PERSON_DTL b
     13        START WITH   sid IN ('A101', 'A100')
     14        CONNECT BY   PRIOR b.emp_mgrs_id = b.sid
     15  ),
     16  flagged as
     17  (
     18      select agent_sid,
     19             path,
     20             start_dt,
     21             end_dt,rn,
     22             case when path like lag(path) over(order by rn)||'%' then 0 else 1 end flg
     23      from paths
     24  ),
     25  summed as
     26  (
     27      select agent_sid,path,start_dt,end_dt,
     28             sum(flg) over(order by rn) sm
     29      from flagged
     30  )
     31  select agent_sid,max(path) path,max(start_dt) start_dt,
     32         min(end_dt) end_dt
     33  from summed
     34  group by agent_sid,sm
     35  order by agent_sid;
    
    AGENT_SID  PATH                                     START_DT  END_DT
    ---------- ---------------------------------------- --------- ---------
    A100       A100,M100,M101,M102,M103,M104            01-JAN-10 18-MAY-13
    A100       A100,M100,M107,M102,M103,M104            20-MAY-13 31-DEC-99
    A101       A101,M105,M106                           01-JAN-10 31-DEC-99
    
  • Windows 7 starts and ends at a black screen

    Windows 7 starts and go through the loading screen and end up a black screen until password with the slider screen try and run across the network normal mode etc. and ends at the screen even please help

    If you can start the computer in an environment of Safe Mode with command prompt , you might be able to make the operational machine through the system restore. Here is an article on how to get if the process.

    Start the restore of the system from a command prompt

    If you can't in SafeMode with command prompt environment on initialize toward the top, you may need to use the recovery partition to reinstall Windows by default. The initialization process differs from manufacturer to another computer, but it involves usually typing a combination of key or combination of keys at startup.

    Note that this process will remove probably all documents, images, programmes, etc. that you have installed/created since owning the computer. for example, it will restore the computer to a State identical to when it left the factory. Use this class as a last resort and consider having a computer technology to remove the disk to retrieve all personal data (documents, photos, etc.) that are irreplaceable.

  • Start and End DateTime calculations

    Dear all

    I have 3 fields start time, end time and hours. I want that if I give hours then the start time should be filled in with the current date and time and end time must be calculated accordingly. Suppose I have hours = 1 then start time should be May 17, 2015 11:25:30 and end time should already be filled in 17 may 2015 12:25:30

    Use this:

            DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
            Calendar cal = Calendar.getInstance();
            System.out.println("Start Time : " + dateFormat.format(cal.getTime()));
            cal.add(Calendar.HOUR, 1);
            System.out.println("End Time : " + dateFormat.format(cal.getTime()));
    

    See you soon

    AJ

  • Start and end date of week 1-5 a month

    I wanted to print the date of beginning and end of the week for a given month.  If the month last_week overlaps the next month, I don't want to print the week5. If the week5 overlap with next month, then it must be printed.

    SELECT

    TRUNC (to_date(:P_DATE,'MM/DD/YYYY'), 'IW') 'SW1', / * start of week 1 * /.

    TRUNC (TO_DATE (: P_DATE, "MM/DD/YYYY '") + 6, 'IW')-1 'EW1', / * end of week you 1 * /.

    NEXT_DAY (trunc (to_date(:P_DATE,'MM/DD/YYYY'), 'IW'), 'Monday') 'SW2 '.

    NEXT_DAY (TRUNC (TO_DATE (: P_DATE, "MM/DD/YYYY") + 6, 'IW'), 'Sunday') 'EW2. "

    NEXT_DAY (NEXT_DAY (trunc (to_date(:P_DATE,'MM/DD/YYYY'), 'IW'), 'Monday'), 'Monday') "SW3."

    NEXT_DAY (NEXT_DAY (TRUNC (TO_DATE (: P_DATE, "MM/DD/YYYY") + 6, 'IW'), 'Sunday'), 'Sunday') 'EW3. "

    NEXT_DAY (NEXT_DAY (NEXT_DAY (trunc (to_date(:P_DATE,'MM/DD/YYYY'), 'IW'), 'Monday'), 'Monday'), 'Monday') "SW4".

    NEXT_DAY (NEXT_DAY (NEXT_DAY (TRUNC (TO_DATE (: P_DATE, "MM/DD/YYYY") + 6, 'IW'), 'Sunday'), 'Sunday'), 'Sunday') 'EW4. "

    NEXT_DAY (NEXT_DAY (NEXT_DAY (NEXT_DAY (trunc (to_date(:P_DATE,'MM/DD/YYYY'), 'IW'), 'Monday'), 'Monday'), 'Monday'), 'Monday') 'SW5. "

    NEXT_DAY (NEXT_DAY (NEXT_DAY (NEXT_DAY (TRUNC (TO_DATE (: P_DATE, "MM/DD/YYYY") + 6, 'IW'), 'Sunday'), 'Sunday'), 'Sunday'), 'Sunday') 'EW5.

    FROM DUAL;

    SW1 EW1 SW2 EW2 SW3 EW3 SW4 EW4 SW5 EW5
    29/12/201404/01/201505/01/201511/01/201512/01/201518/01/201519/01/201525/01/201526/01/201501/02/2015

    Is it possible to get it without using the next_day() several times for each week and to limit the accumulation of the week last in a month.

    Check my last answer. And if this isn't what you need, then the expected results for each month in 2015.

    SY.

  • Simple validation on the start and end dates

    Apex 4.2

    I'm trying to create a script of validation on my start date and end date. A simple validation indicating the start date must be less than the end date. Because apex deals my fields of date as a string, using an expression of pl/sql as P101_START_DATE < = P101_END_DATE does not work. This may seem like an easy question, but I'm unable to create this simple validation. Any help would be greatly appreciated. Thanks in advance!

    Take a look how the TO_DATE plsql function works... ie... to_date(:P101_START_DATE,'mm-DD-yyyy')<=to_date(:P101_END_DATE,'mm-dd-yyyy'),>

Maybe you are looking for

  • using people in the sierra of macOS photos

    I have three different thumbnails in people named well how to combine them.  I have several empty spaces where people should be, but there is no picture, how to remove them.  It is not clear how to use people without label.  Just choose again and aga

  • Satellite NB10 A986 webcam problem

    Hello Please help me, I have a problem of blur using the webcam with Skype, and even with the camera utility windows 8.1, videos on Skype and photos taken by webcam are blurry (sorry for my English!).I don't think that there is a plastic sticker on w

  • Display exceeds the size of the monitor screen

    Hello I just bought a HP 5208uk (without a monitor). Connected to a (digital) TV via vga on a resolution of 1024 x 768 and dvi on the 1080ix60 resolution (two settings came automatically). The display of the Office is outside the borders of the scree

  • Synaptics Touchpad driver overwhelming

    Hello I face just for the past few days where the touchpad doesn't work - such as scrolling with the touchpad. I must go to the folder of the synaptics driver and start SynTPEnh.exe manually. But after some time, the opening of the files, browsers, t

  • How to move to windows 10?

    Currently, I have vista OS and I was wondering what I need to do to achieve 10 victory? Thanks :)