Calculations of dates for the gaps and overlaps

Oracle version: 11.2.0.3

Platform: Linux

EmpNo position start_dt end_dt

1 X 01/01/2008-01/02/2010

1 Y 01/02/2009-12/31/2012

1 X 02/01/2012-04/01/2013

1 Z 2012 12/31/5 / 01 / 2012

1 O 01/05/2013 presents

I need to find the exact period the employee has worked for the company in a particular situation. The query must be able to calculate the overlap/gaps as a result

For example in this case, the result must be

Days of position empno Total_Days

1 x 1156 2943

1 1543 2943 y

1             z               244        2943

Thank you

Kevin

SQL > select empno, position, hard

2, sum (hard) earlier (partition by empno)

3 of

(4)

5. Select empno, position, sum (end_dt - start_dt) hard

6 t

Group 7 by empno, position

8)

9;

EMPNO P HARD TOT

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

1 X 1157 2944

1 1543 2944 Y

1 Z                  244                 2944

Don't know exactly what you mean by cross-checking.  Can an employee cause two different positions at the same time?  Your sample data does not display it.

Tags: Database

Similar Questions

  • How to get back my data for the health and the watch Apps once I've restored my phone?

    How to get back my data for the health and the watch Apps once I've restored my phone?

    From the backup, you're going to be restoration.

    If you back up to iTunes, make sure that it is an encrypted backup.

  • Find the gap and overlap

    Hi gurus

    I have the following data:

    Data

    SELECT rule_id 100, Min_age 18, Max_age 34, 'SINGLE' status, 1 double bill_id

    UNION ALL

    SELECT rule_id 100, Min_age 18, Max_age 34, the status of 'FAMILY', 3 bill_id FROM dual

    UNION ALL

    SELECT rule_id 100, Min_age 18, Max_age 34, 'COUPLE' status, 5 double bill_id

    UNION ALL

    SELECT rule_id 100, Min_age 35, 44 Max_age, 'COUPLE' status, 8 double bill_id

    UNION ALL

    SELECT rule_id 100, Min_age 18, Max_age 34, 'COUPLE' status, 9 double bill_id

    UNION ALL

    SELECT rule_id 100, Min_age 20, Max_age 25, 'COUPLE' status, 10 double bill_id

    UNION ALL

    SELECT rule_id 100, Min_age 35, 44 Max_age, "SINGLE" status, 11 double bill_id

    UNION ALL

    SELECT rule_id 100, Min_age 46, 50 Max_age, 'COUPLE' status, 12 bill_id FROM dual;

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

    The query result

    rule_id Min_age Max_age status bill_id

    100                     18                     34                 SINGLE           1

    100                     18                     34                 FAMILY           3

    100                     18                     34                 COUPLE         5

    100                     35                     44                COUPLE          8

    100                     18                     34                COUPLE          9

    100                     20                     25                COUPLE         10

    100                     35                     44                SINGLE           11

    100                     46                     50                COUPLE         12

    Power required

    100                     18                     34                COUPLE          9

    100                     20                     25                COUPLE         10

    100                     46                     50                COUPLE         12

    Rules

    1. record may be overlapping, but same Min_age, Mix_age and rule_id even with records of different status, for example the first 3... (bill_id 1,3,5) but if you can look in the folder bill_id = 9 status couple is repeated against the same Min_age, Mix_age and rule_id even if I need to get this record...

    2 - the need to fetch the record of overlap as bill_id = 10 because its between 18 and 34.

    3 day-1 gap is ok if you see bill_id = 5 max_age = 34 and next Min_age = 35 so this record is ok, but if you look in bill_id = 11 his max_age = 44 then next Min_age = 46 ways to the gap... so I need this file too

    I try my level best to convey my message, but if you have any questions please let me know.

    Concerning

    Shu

    Something like:

    Select *.

    of tbl t1

    When there is)

    Select 1

    of tbl t2

    where t2.status = t1.status

    and)

    T1.MIN_AGE between t2.min_age and t2.max_age

    or

    T1.MAX_AGE between t2.min_age and t2.max_age

    )

    and t2.bill_id<>

    )

    or min_age! = ()

    Select nvl (max (t2.max_age) + 1, t1.min_age)

    of tbl t2

    where t2.status = t1.status

    and t2.max_age<>

    )

    /

    RULE_ID MIN_AGE MAX_AGE STATUS BILL_ID
    ---------- ---------- ---------- ------ ----------
    100 18 34 COUPLE 9
    100 20 25 10 COUPLE
    100 46 50 TORQUE 12

    Scott@ORCL >

    SY.

  • App for the time and payroll sheet calculations

    My daughter in hospitality makes work so much split and travel on a Saturday and Sunday. I am looking for an application that we can punch in his hours for the week and be able to do the calculation of salary based on the appropriate hourly rate so that we can keep control of when it is paid as it's done correctly. Essentially, I'm lookin for an app connects timesheet information to the payroll data. Such an application exists and if so can anyone recommend one? Happy to pay for an if need be.

    Hello alissah6,

    Numbers from Apple is what I would recommend as far as doing calculations with a simple formula. You can learn more about this here.

    The application costs $14.99, however it is packed and has more than 30 models - not to mention, you can also create your own if necessary.

    I would check it out certainly if I'm looking for a few terms related to pay calculation in the App Store.

    Thank you

    James.

  • Re: Release Date for the Tecra A10 - 18 p and A10 - 15 c

    Could someone tell me the release date for the Toshiba Tecra A10 - 18 p and A10 - 15 ° C. What would be the estimated price for these two models.

    Thank you

    I didn't find the release date of this laptop models.
    On the Europe of Toshiba page-> Products->-> Tecra laptops, you will find a whole list of different series and Tecra models.
    Right now I find only the info that these laptops will be available soon.

  • Silverlight-during the installation receives an invalid message of (1) data for image corrupted and checksum (2). It is a Mac.

    Silverlight-during the installation receives an invalid message of (1) data for image corrupted and checksum (2). It is a Mac.

    Anyway to install Silverlight on a Mac. Use with Netflix
    pprimm

    http://www.Silverlight.NET/

    Silverlight forums: http://forums.silverlight.net/

    -steve

  • A-team - MAF Persistence Framework - is available for the MAF and it is an approach recommended by Oracle for Application Data Sync?

    Hi OTN community.

    My query is on Oracle team Persistence framework (http://www.ateam-oracle.com/going-mobile-with-adf-implementing-data-caching-and-syncing-for-working-offline/).

    It is available for the MAF and it is an approach recommended by Oracle for the implementation of data synchronization?

    Can anyone please share their experience using this extension.

    We are currently reviewing the best approach for the implementation of data synchronization.

    Best regards

    Deepak

    See: persistence of the MAF Oracle for SQLite

    Frank

  • PowerCLI - there cmdlets to browse the store of data for files/directories and their creation?

    Hello

    PowerCLI - there cmdlets to browse the store of data for files/directories and their creation?

    If Yes, can you please let me know.

    I took a glance at the reference of the cmdlet, but can not find...


    Kind regards

    Dreamer

    You can use the data store provider.

    It is documented in the vSphere PowerCLI Administration Guide that was installed with PowerCLI.

  • I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows?

    I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows so that I can do the calculations?

    If you start the https://forums.adobe.com/welcome Forums Index

    You will be able to select a forum for the specific Adobe products you use

    Click on the symbol "arrow down" on the right (where it is said to see all our products and Services) to open the drop-down list and scroll

  • How do I remove the launch date for the safe in FF portable ESR 31

    How do I remove the launch date for the safe in FF portable ESR 31. Is it possible that - by pressing the SHIFT key when you launch firefox shows the option of safe mode - off and close the browser.

    See also:

  • Could re: Anyone tell me the release date for the Toshiba Tecra S10-106

    Could someone tell me the release date for the Toshiba Tecra S10-106. What would be the estimated price for this model.

    Thank you

    I already posted this in your other thread on Tecra A10.

    On the Europe of Toshiba page-> Products->-> Tecra laptops, you will find a whole list of different series and Tecra models.

    Right now I find only the info that these phones will be available soon.

    You may need to wait a bit...

  • Write delay failed unable to save all the data for the file $Mft

    Have a frustrating problem.  Help is greatly appreciated.  Learned the hard way and lost a dwg important issue which was unrecoverable.  Bought a new drive external hard seagate.  Could not back up the entire system with software pre-installed.  Download acronis true image home 2011.  Tried to backup system.  Receive error when trying to backup messages; 'Delay to failure of Scripture; Reading of the sector; Windows was unable to save all the data for the file $Mft. The data has been lost.  Have tried many fixes.  Unable to disable write caching method (grayed out / unclickable).  Played regedit 'EnableOplocks' is not listed to select.  Attempted to run microsoft 'fix it' and got the blue screen of death.  Short hair out of my head.  Suggestions appreciated.

    I don't know where Microsoft 'Technical support engineers' get their information.

    Write caching without a doubt "does apply to external hard drives", but it is usually disabled to prevent to sort the problem you are experiencing.

    I've seen several positions reporting to the same question that you do.  All of these positions were with SATA drives.  Is your Seagate eSATA drive?

    The disc is recognized as an external drive in Device Manager?  In Device Manager, go to the drive properties dialog box and click the policies tab.  An external drive should have two options: "Optimize for quick removal" and "Optimize for performance".  An internal hard drive shows the options as gray (with 'performance' selected), but there should also be a checkbox "Enable disk write cache" under the second option.

    What shows in your policies tab?

    If I understand correctly, "writeback" or "write behind" is implemented by disc material or its pilot.  If the option is not available on the drive properties > policies tab, I would suggest to contact Seagate support.

  • How to connect an expiration date in the ID and the password set cached?

    I have windows 2003 race. I would like to know if there is any kind of code and where it must be added have log vpn users in the local network before they user of the laptop to go on the web?

    In other words, how I plug in and the expiration date for the caching of id and password?

    I'm not sure that's what you want.  You can change your machine such as passwords are cached at all, but then a person could not connect to his laptop unless it is connected to your domain, when it connects (forget not to use your computer on a plane).  If you want to control access to the internet, many businesses use a Proxy Server with a password to regulate the internet connection.  See if these MS articles shall apply:

    "Caching of security credentials in Windows Server 2003, Windows XP, and in Windows 2000"
      <>http://support.Microsoft.com/kb/913485 >

    "Cached domain logon information.
      <>http://support.Microsoft.com/kb/172931 >

    HTH,
    JW

  • Update error... I tried to update for the month and each time it fails

    I tried to perform updates for the month and each time it fails.  I get the same error message... Code 646 WIndows has encountered an unknown error.  I did troubleshooting and you are unable to find assistance.  I don't know much about the workings of the computer, but I know that I should be able to perform these updates.  I think I need it too.  I have 9 at this stage that it cannot load.  Help, please!

    I tried to perform updates for the month and each time it fails.  I get the same error message... Code 646 WIndows has encountered an unknown error.  I did troubleshooting and you are unable to find assistance.  I don't know much about the workings of the computer, but I know that I should be able to perform these updates.  I think I need it too.  I have 9 at this stage that it cannot load.  Help, please!

    This link leads to a response from Bobby Mi, moderator.
    Date: July 6, 2010
    http://social.answers.Microsoft.com/forums/en-us/vistawu/thread/18449f60-C149-4EAF-B8E6-a2880cd7232b

    Bobby Mi response will lead to this tutorial from Microsoft Support:
    http://support.Microsoft.com/kb/2258121

    Hope this can help solve your problem.
    For the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

  • How to create a date for the restoration of the system when there is no previous restore date.

    When you try to create an earlier date for the restoration of my pc (windows 8.1) for the first time (no previous restore point) the only option I get is to create point of restoration of the date and time of today. I need to restore to an earlier date. Does anyone have a solution?

    You can click on the box "Show more restore points" to view the older, but they may not be as reliable (they may fail to apply or they may not actually work).

    If you do not see the box to check, or the oldest, so it is not of the ancients still show.  If this is the case, you will need to use the 'Refresh PC'.

Maybe you are looking for

  • Cannot start addon because there is no longer the 'Tools' menu

    I can't launch addon because there is no longer the 'Tools' menu. Is there a solution?

  • Satellite Pro L850 - i5 3210 M shared memory allocation

    Hello I am a happy owner of this laptop great and I added an extra RAM to consider to 8 GB. All data sheets on the State of sites detailing the gpu that can be assigned up to 1.7 GB of memory share. Previous experience from other computers is that th

  • Install network protocol: Windows TCP/IP

    I tried to intall a professional printer to my PC and I get the following message. Install the following network protocols: Windows TCP/IP I found the location on the network Conections where I supposed to insert a number, but what number shoud I typ

  • horizontal scrolling in a spreadsheet

    When scrolling horizontally in a spreadsheet (e.g. google docs) I want the scroll bar to move left and right, as it is with scrolling vertical, rather than scroll through individual cells. Is this possible in windows 7? This seems the same in chrome

  • any transfer of api files

    I am building an app that would charge a server img, I want to be cached so I wont have to search each time. but I don't know how to do this. I prefer to store these files from within my app cache / data directory. for example: $home/data/cache1.jpg