Continuous punches

Hello

I have the following table

create table punchdetails)

Select 1 empid, to_date (March 21, 2015 07:55 ',' dd/mm/yyyy hh24 ') inpunch, to_date (March 21, 2015 09:00 ',' dd/mm/yyyy hh24 ') of all outpunch the double union

Select 1 empid, to_date (March 21, 2015 09:30 ',' mm/dd/yyyy hh24 ') inpunch, to_date (March 21, 2015 13:00 ',' dd/mm/yyyy hh24 ') of all outpunch the double union

Select 1 empid, to_date (March 21, 2015 15:00 ',' dd/mm/yyyy hh24 ') inpunch, to_date (March 21, 2015 16:30 ',' mm/dd/yyyy hh24 ') of all outpunch the double union

Select 2 empid, to_date (March 21, 2015 08:00 ',' dd/mm/yyyy hh24 ') inpunch, to_date (March 21, 2015 16:00 ',' dd/mm/yyyy hh24 ') of all outpunch the double union

Select 2 empid, to_date (March 22, 2015 07:55 ',' dd/mm/yyyy hh24 ') inpunch, to_date (March 22, 2015 12:00 ',' dd/mm/yyyy hh24 ') of all outpunch the double union

Select 2 empid, to_date (March 22, 2015 12:25 ',' dd/mm/yyyy hh24 ') inpunch, to_date (March 22, 2015 16:30 ',' mm/dd/yyyy hh24 ') outpunch the double

)

If the gap between punch output and then in punch is less than or equal to 30 minutes, these punches are regarded as continuous.

Here as the punch of employee 1 out at 09:00 but he'll be back at 9:30, that gap is allowed and it is treated as he worked from 07:55 until the end of the second punch is to say 13:00

Expected result is

EMPID                IN                               OUT

1 21/03/2015-07:55 03/21/215 13:00

1 21/03/2015 15:00 03/21/215 16:30

2 2015-21/03 08:00 21/03/215 16:00

2 21/03/2015-07:55 03/21/215 16:30

Can it be done in a query?

Help, please

I use oracle 10g

Hello

Here's a way

WITH got_new_grp AS

(

SELECT empid, inpunch, outpunch

CASE

WHEN inpunch - LAG (outpunch) OVER (PARTITION BY empid

ORDER BY inpunch

) > 30 / (24 * 60)

THEN 1

END AS new_grp

OF punchdetails

)

got_grp AS

(

SELECT empid, inpunch, outpunch

, CHIEF (new_grp) OVER (PARTITION BY empid

ORDER BY inpunch

) AS the grp

OF got_new_grp

)

SELECT empid

MIN (inpunch) AS inpunch

MAX (outpunch) AS outpunch

OF got_grp

GROUP BY empid, grp

ORDER BY empid, grp

;

I guess that the combination (empid, inpunch) is unique.

Here's how it works:

It is essentially a problem of GROUP BY.  We want to show that the inpunch earlier and later outpunch in each group.  It's that the main request.

The tricky part of GROUP BY.  We can use the LAG function analytic to see where the new groups to start (what does the subquery got_new_grp) and then use the analytical function another (such as COUNT or SUM) to see how many groups have started from each line (which the subquery got_grp).

Tags: Database

Similar Questions

  • I have an e-mail failed to punch continues & cannot get rid of

    I entered an email address that wasn't except & received an errow message. It says I have to send an email but it is impossible to send or get rid of it.

    Go to the Outbox and delete the message.  If it will not erase, then go to file | Work offline and then try to delete it.

    Steve

  • Punching of Anomalies

    Hello

    I now of paintings

    TBL1: WORKTIMINGS

    This table stores daily worktimeing of employees.

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

    EMPID STARTTIME ENDTIME

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

    TBL2:OVERTIME

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

    EMPID OTFRM OTTO

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

    TBL3:SETTINGS

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

    PRESHIFTMINS POSTSHIFTMINS

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

    TBL4:PUNCH

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

    EMPID INPUNCH OUTPUNCH

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

    There is only one line in the table above.

    Suppose that preshiftmins = 30 and postshiftmins = 60

    This means, the employee can punch 30 minutes before

    his shift starts and that the employee is allowed to punch in the 60 minutes after his shift.


    The same rule applies to overtime. That is to say

    the employee can punch 30 minutes before

    his additional starts and that the employee is allowed to punch in the 60 minutes after overtime.

    I need a punching based on the above rule exception report.

    Here an exception is if overtime begin in the 60s (according to the table of parameters) minutes after his shift.

    the employee can continue up to the end of overtime.

    For example:

    worktimings for employee 1

    21/01/2014 08:00 to 16:00 21/01/2014

    Overtime for the same day is 21/01/2014 16:30 to 18:30 21/01/2014

    So to this day, all the punches between 21/01/2014 07:30 and 19:30 01/21/2014 are valid.

    For example: 2

    ====

    worktimings for employee 1

    21/01/2014 08:00 to 16:00 21/01/2014

    Overtime for the same day is 21/01/2014 18:30 to 21/01/2014 23:30

    So to this day, all the punches between 21/01/2014 07:30 and 17:00 21/01/2014 are valid.

    also punches between 21/01/2014, 00:30, 18:00-22/01/2014 are valid.

    I need a report to know the invalid punches.

    For example:

    =======

    In the following example 2 punches are not valid.

    21/01/2014 06:00 to 12:00 21/01/2014

    21/01/2014 12:30 to 21/01/2014 23:30

    I use oracle 10g

    examples of data

    ============

    create the table settings (select 1 empid, 30 preshiftmins, 60 double postshiftmins);

    create additional table as hours

    (select 1 empid, to_date (21 January 2014 16:30 ',' mm/dd/yyyy hh24 ') otfrm, to_date (21 January 2014 23:30 ',' mm/dd/yyyy hh24 ') double otto)

    );

    create the table worktimings as

    (select 1 empid, to_date (21 January 2014 08:00 ',' dd/mm/yyyy hh24 ') starttime, to_date (21 January 2014 16:00 ',' dd/mm/yyyy hh24 ') double endtime)

    Union of all the

    Select 1 empid, to_date (22 January 2014 00:00 ',' dd/mm/yyyy hh24 '), to_date (22 January 2014 08:00 ',' dd/mm/yyyy hh24 ') of double

    Union of all the

    Select 2 empid, to_date (21 January 2014 08:00 ',' dd/mm/yyyy hh24 '), to_date (21 January 2014 16:00 ',' dd/mm/yyyy hh24 ') of double

    );

    create table like punches

    (select 1 empid, to_date (21 January 2014 08:00 ',' dd/mm/yyyy hh24 ') inpunch, to_date (22 January 2014 08:00 ',' dd/mm/yyyy hh24 ') outpunch the double)

    Union of all the

    Select 2 empid, to_date (21 January 2014 08:00 ',' dd/mm/yyyy hh24 '), to_date (January 22, 2014 12:00 ',' dd/mm/yyyy hh24 ') of double

    Union of all the

    Select 2 empid, to_date (21 January 2014 00:00 ',' dd/mm/yyyy hh24 '), to_date (22 January 2014 18:00 ',' dd/mm/yyyy hh24 ') of double

    );

    Here, the output would be

    EMPID INPUNCH OUTPUNCH

    2 21/01/2014 00:00 21/01/2014-18:00

    Help, please

    Hello

    Krishna Devi Vinayaka says:

    On this basis, I arrived without authorisation periods IE. space between each retailer periods.

    Then I select all the inpunches and the punches that straddles these unauthorized periods.

    Here, while getting the next start time, there are two questions.

    (1) next launch may be less at the present time end

    (2) if there is no other record next departure is null.i this case, I select payroll enddate IE. 20/02/2014.

    ...

    I think you are taking the wrong approach.  You try to identify the periods not allowed as the gaps between the authorized periods and then see if punch took place in a non-authorised period.  It seems that it would be easier to find the punches that didn't take place during authorized periods, which is what I did in response #1 two weeks ago, and you said which produces erroneous results anyway.  If I understand the problem now, not only must the in-punch out - Punch of each line in certain authorized period, the two hallmarks of this line must be in the same period allowed, where a 'permitted period' is 1 or more lines of the worktimings tables and/or overtime which overlap, or at least have not a gap between them.  This is what the query in response #10.  The column new_shift (calculated in the subquery called got_new_shift) identifies if a work period begins a period authorized or not, seeking at all times of previous work via the analytical MAX function).  If all of these earlier periods ended before the beginning of the current, then (and only then) it starts a new period authorized.  The following subquery, got_shift_num, uses the analytical ACCOUNT works to see how many authorized periods have started to date, indicating which authorized period each work period belongs.  Once we know, we can use the functions MIN and MAX of aggregation for a fine when each authorized period begins and ends.  This is what the movement of subquery combined.

  • continuing a story

    How jump (continue) a history of information from one page to the other letter?

    I use 6 Pages with OS X Sierra, 10.12.

  • Continuity of Clipboard does not not on my Mac OS Sierra?

    I have a MacBook Pro in early 2011 and an iPhone 5, both set to update to the latest Mac OS and iOS.

    Is Bluetooth on both devices, but when I try to copy and paste a text of notes to notes from one device to another, it does not.

    I have tried rebooting without success: no PES support? Tnxs

    Hello Jet787,

    Thanks for this info and choosing the communities Support from Apple. I know the importance of being able to use the Univeral Clipboard feature is for you! If I understand correctly, you cannot copy / paste, even after rebooting. I would check the requirements and the rest of the steps in this article:

    To use the universal Clipboard, your devices must meet the requirements of continuity system. They must also be on the same network Wi - Fi and Bluetooth included in each (33 feet or 10 meters), and have Bluetooth and transfer enabled in the preferences system (on your Mac) and places (on your iOS devices). You must be connected to iCloud by using the same Apple ID on all your devices.

    macOS Sierra: copy and paste between devices

    See you soon!

  • I recently blocked my macbook pro using find my iphone app now, he continues to display in 'your computer is disabled. Try again in 60 minutes. I tried pressing the option key and also the R button at startup. same thing is happening.

    I recently blocked my macbook pro using find my iphone app now, he continues to display in 'your computer is disabled. Try again in 60 minutes. I tried pressing the option key and also the R button at startup. same thing is happening.

    Hi iambjan,

    I understand that your MacBook Pro has been lost by the intermediary of find my Mac mode. Fortunately, you can go to the off mode lost through the steps described below.

    You can disable the lost Mode by entering the password of the device, or by following the steps below. Alternatively, you can follow the steps below to change the details displayed on your lost device.

    Note: If your credit cards and debit to pay Apple have been suspended because you put your iPhone in lost Mode, when you disable lost Mode and reconnect to iCloud, you can continue using your cards.

    1. Go to find my iPhone on iCloud.com.

      If you don't find my iPhone on iCloud.com, your account has fair access to the web features only iCloud. To access find my iPhone and other iCloud features, set up on your device iOS or Mac iCloud.

    2. Click on all devices, and then select the device that is lost.

    3. Click on lost Mode, then change the information or lost the stop Mode.

    If you cannot use lost fashion as find my iPhone is not configured on your lost device, see the article by Apple Support If your iPhone, iPad or iPod touch is lost or stolen.

    SEE ALSO
    Remove credit and debit of the portfolio (or book) maps

    iCloud: use lost Mode
    https://support.Apple.com/kb/ph2700

    Kind regards.

  • Continuity and transfer works do not (Solution)

    I open this topic just to share my solution to the problem that some of you may face too.

    After upgrading to Mac OS Sierra, the characteristics of continuity has stopped working completely between my MacBook and iPhone, so I did all the procedures standards withoutsuccess:

    -Disconnect icloud on both devices and connect again

    -Reset the PRAM on Mac

    -Reset network settings

    -Turn on bluetooth works (all devices)

    -Creating a new user on mac to see if it was a problem with the specific user (without success)

    -Restart both devices again

    -Reset the router (just in case)

    And after a day trying to fix it, I gave up. But the next morning (today), I decided to try one last thing, and to my surprise, everything returned to normal instantly and magically.

    Here's what I did:

    On your mac,.

    1. disable the bluetooth

    2. finder-> go to folder...->/Library/Preferences /.

    3. delete the file com.apple.Bluetooth.plist

    4. turn on the bluetooth

    Boom. Everything returned to normal.

    I hope this helps someone who has the same problem I was. For any question, please check below.

    lucasvallim wrote:

    On your mac,.

    1. disable the bluetooth

    2. finder-> go to folder...->/Library/Preferences /.

    3. delete the file com.apple.Bluetooth.plist

    4. turn on the bluetooth

    You can check that the correct path is the one as written:

    / Library/Preferences /.

    and is not

    ~/Library/preferences/

  • Try to connect to my yahoo on Safari takes me in a continuous loop to the login page. It works very well with Firefix.

    Try to connect to my Yahoo on Safari brings back me in a continuous loop to the login page. My registration using Firefox works fine.

    IM using ios10 on an iPhone 6 s

  • If the battery is fully charged charge can it continue to be plugged?

    Maybe the battery can be damaged if she continue to be plugged to the charger unit once it has been fully charged?

    No, it will not damage the battery.

    You can reload at any time, for any period of time.

    You can use the computer while loading.

    Don't deplete the battery at a low level.

  • Will iPad 3rd Gen continue to get patches

    I know that this is never going iOS 10, but Apple will release patches security and bug fixes to older iOS devices?  I know they did for old OS X systems for some time.

    Will be continue them to be fixes for iOS devices that cannot handle iOS 10?

    (IPad device 3)

    We end users like you, so we have no special knowledge of what Apple will or will not do. Like you, I know that they have published updates of security for older OSX versions several steps back, but we will have to wait and see. I'm in the same boat. I have an iPad 2 which works very well with iOS9 but I don't use it enough to justify the upgrade to a newer model that runs iOS 10.

  • I've been upgraded to El Capitan and electricity went off and stopped the session.  I don't have time to continue for 12 hours.  It is the CV.  How can I cancel until I have more time?

    I've been upgraded to El Capitan and electricity went off and stopped the session.  I don't have time to continue for 12 hours.  It is the CV.  How can I cancel until I have more time?

    Hello nancy milano,.

    Thanks for this info and choosing the communities Support from Apple. I know how important is able to complete your update to El Capitan at a later date! The good news is that you can simply delete the "install Mac OS X" install app in the Applications folder on your Mac. Then you can open the Mac App Store when you're ready to update and restart the download from the tab updates or searching through the Mac App Store for El Capitan. This is a resource that explains the process of update more:

    Update of OS X El Capitan

    See you soon!

  • Apple maps address and continuous route of incorrect information after four years

    The address of the map and driving directions in IOS devices 3/4 Ave., Almena, WI 54805 continues to be incorrect in Apple Maps to 369 12.  We have presented more than 15 applications over the past 4 years to this fixed and submitted two photos geocoded with delivery address and Barron County, WI property and survey records of SIG showing the right address but this remains unclear.  On an IOS device, if you enter the address 369 12 3/4 Ave., Almena, WI 54805 map will take you to the correct location on the map, but the map shows an address of 369 12 3/4 Ave., Turtle Lake, WI 54889.  And if you have driving directions to 369 12 3/4 Ave., Almena, WI 54805 that will correctly identify the map take you somewhere 369 S 4th Ave, Alpena, MI 49707, 500 miles.

    Apple is not regularly monitor the discussions. These are mostly a user in discussions.

    Send feedback to Apple. They will not respond, but at least know that there is a problem or a suggestion for change. If enough people send feedback, it can get change / suggested the problem solved as soon as possible.

    Your comments

  • Don't play do not continually album for ios10

    I've just updated to iOS 10.0.1. When I want to play an entire album, the player plays the first track right and then continually plays the first track anywhere. I have to manually switch to the next track and so on to play the entire album. Is it possible for an album to play at all times automatically?

    Hi peraltafbyahoo,

    Thank you for using communities Support from Apple!

    I see in your message when you try to play a song through the music app, it covers just the song rather than continue on. This sounds like the repeat button may have been activated. You can check this by doing the following:

    Control playback. Tap a song to play and show the MiniPlayer. Tap the MiniPlayer to display the now playing screen, where you can do the following:

    Repeat steps. Glisser slide upward, then press on to repeat an album or a playlist. Double click to repeat one piece.

    Play music

    See you soon.

  • iCloud/continuity does not work with my Mac or iPhone now

    I was really holding this problem for a very long time now because it's really a "first world problem", but in the past year continuity and iCloud were either non-existent or not working properly on my iPhone 5 s (32 GB) and mid-2014 13 "(2,6 GHz/8 Go/128 SSD) retina MacBook Pro (and now it just feels like I use old devices when I'm not."

    They work on the latest versions of iOS and Mac OS El Capitan, are on the same WiFi network at home or at school, have all two Bluetooth-enabled, and are both signed in my Apple ID iCloud

    Last year when I had the time, I reset the settings, wiped and restored the iPhone, etc, to try to get continuity works again. Nothing seems to work, and so that the whole process has been somewhat of a breeze on the release of these two operating systems, for some reason any he didn't work on my devices. I'm really ideas at this stage on how I can get the work continuity (the alternative at this moment is iCloud tabs in Safari).

    With iCloud, the issues are not as complex, but the photo stream is not working properly. If I take pictures on my iPhone that do they not appear in a few hours on my Mac, and if I add a bunch of pictures in pictures on the Mac, appear at all on the iPhone. I have all iCloud settings enabled for Photos and it's still buggy.

    I use Apple products since kindergarten and I consider myself to be a loyal customer. It would be a shame if I can't find a way to solve what should be a simple problem.

    Thank you for your help in advance.

    I guess you have tried to sign your iCloud (on all devices) account, signing in?  If you tried and it did not work, and this problem is ongoing for you for a year, my next suggestion would be to call Apple Support (link at the bottom of the page) or make an appointment with an employee at the Genius Bar in an Apple store.

  • My Airport Express will randomly start flashing orange and I have to unplug it to make it back to the green.  Wifi continues to operate even when the light is orange flashing.  Anyone know why this is happening?

    My Airport Express will randomly start flashing orange and I have to unplug it to make it back to the green. Wifi continues to operate even when the light is orange flashing. Anyone know why this is happening?

    The next time you see the flashing light amber...

    Open Finder > Applications > utilities > AirPort Utility

    Click on the image of the AirPort Express

    If you see a button update, click on update the firmware on the airport

    Otherwise, find status and click on the little orange dot it. A message will appear to say why the airport complained and suggest a remedy for the issue.

Maybe you are looking for

  • I want to download El Capitan, but KEEP the installer

    I want to download El Capitan, but KEEP the installation program. I have a partitioned hard drive, (I need to keep old versions of Mac OS because I do video editing). How can I keep El Capitan Installer?   As many know, in the world of the downloaded

  • Display on Satellite L850-1PD - no warranty case problem?

    _Old year_I contacted Toshiba web support December 5, 2013.On 9 December, I received an email from an official assistance centre who asked me to send him a picture of the screen.After that, I sent this picture what they told me to send my phone to th

  • On the Satellite Pro L500 - 1 6 vibrating screen

    I have a Satellite Pro L500 - 1 6, operting system is windows 7.Since I bought the laptop I've known vibration of the screen.The problem is more acute when I'm running java on firefox and then open a program like Outlook and try to use the drop-down

  • HP Pavilion TouchSmart 15-b100: System Bios password disabled 5976 9460 code

    Hi all! Could someone help me with the Bios password I need to type after trying 3 times and get the system off code 59769460? I know its running Windows 8, but I'm not sure of the version... I would be really grateful if someone could help me with t

  • Why do I often have the same automatic update from Microsoft on my PC?

    GREETINGS, I GET THE SAME DOWNLOAD UPGRADE OF MICROSOFT I HAD ALREADY INSTALLED ON MY PC. IT CEASES TO APPEAR ON THE SYSTEM TRAY TO MY PC WITH THE ANNOUNCEMENT OF AN UPDATE, I HAD ALREADY INSTALLED ON MY PC. WHAT IS PAST WITH THE MICROSOFT AUTOMATIC