Out of eligibility of the days

Hello


I have the following table ATTENDANCE

DATE

OFF

UNPAID

21/07/2015

unpaid

22/07/2015

unpaid

23/07/2015

unpaid

24/07/2015

off

25/07/2015

unpaid

26/07/2015

unpaid

27/07/2015

28/07/2015

29/07/2015

off

CREATE TABLE PRESENCE AS

(

SELECT 1 EMPID, DOUBLE TO_DATE('21/07/2015','DD/MM/YYYY'), 0 OFFDAY, 1 OUTSTANDING OF ANY UNION RDATE

SELECT 1, TO_DATE (JULY 22, 2015 ',' DD/MM/YYYY ""), 0, 1 DOUBLE UNION ALL

SELECT 1, TO_DATE (JULY 23, 2015 ',' DD/MM/YYYY ""), 0, 1 DOUBLE UNION ALL

SELECT 1, TO_DATE (JULY 24, 2015 ',' DD/MM/YYYY '), 1, 0 DOUBLE UNION ALL

SELECT 1, TO_DATE (JULY 25, 2015 ',' DD/MM/YYYY ""), 0, 1 DOUBLE UNION ALL

SELECT 1, TO_DATE (JULY 26, 2015 ',' DD/MM/YYYY ""), 0, 1 DOUBLE UNION ALL

SELECT 1, TO_DATE (27 JULY 2015 ',' DD/MM/YYYY '), 0, 0 DOUBLE UNION ALL

SELECT 1, TO_DATE (28 JULY 2015 ',' DD/MM/YYYY '), 0, 0 DOUBLE UNION ALL

SELECT 1, TO_DATE (JULY 29, 2015 ',' DD/MM/YYYY '), 1, 0 OF THE DOUBLE

);

For each day offday = 1 means that it is a stop for the employee.

and unpaid = 1 means that it is an unauthorized absence and a full day is unpaid.

Here a rule to give OFF an employee is that, in previous 5 days that his unpaid account must be not greater than or equal to three, or its judgment day become outstanding.

so I used after application to do the same thing in a single select here

Select

EMPID,

RDATE,

-case offday = 1 and

Sum (UNPAID) over (partition by empid arrested by rdate rows between 5 preceding and 1 preceding) > = 3

then 0

to end another OFFDAY as offday.

-case offday = 1 and

Sum (UNPAID) over (partition by empid arrested by rdate rows between 5 preceding and 1 preceding) > = 3

then 1 other UNPAID end as non-PAID

ATTENDANCE;

The result is

EmpID date off unpaid

121/07/201501
122/07/201501
123/07/201501
124/07/201501
125/07/201501
126/07/201501
127/07/201500
128/07/201500
129/07/201510

But the employee has already lost eligibility for the day off, 24, his previous outstanding account 5 days 29 becomes three and he is not eligible for the 29 stop too.

expected results

EmpID date off unpaid

121/07/201501
122/07/201501
123/07/201501
124/07/201501
125/07/201501
126/07/201501
127/07/201500
128/07/201500
129/07/201501

Is it possible to get this output from a query? or do I have to use a procedure that checks and update each lines while I'll get the updated records updated?

Help, please

I use oracle 10g

Hello

Krishna Devi Vinayaka says:

Hi Karthik,

Thanks for the reply that he.

Why are you ordering records by empid only?

It must be ordered by rdate to rethink the role of the previous lines? ...

I don't know that it was a typo.  It is never logical PARTITION BY and ORDER BY the same expression in any single function.

You can't solve this problem with only analytical functions.  This is a recursive problem.  Analytical functions can get correct results ranked N based on the raw data on the N-5 through N - 1 lines, but in this problem, the results ranked N depend on derivatives results (not the raw data) on the N-5 lines by N - 1.  You can't tell if July 29 is considered as not paid until you have determined if July 24 is unpaid.  You can probably do it using CONNECT BY or with a recursive (available in Oracle 11.2 and upwards) WITH clause, but I think that the best solution in Oracle 10 is MODEL.

Here's a way to do it:

SELECT empid, rdate, offday, unpaid

ATTENDANCE

MODEL PARTITION BY (empid)

DIMENSION OF (rdate - MIN (rdate) OVER (PARTITION BY empid) LIKE d_num)

MEASURES (rdate

offday

unpaid

)

REGULATION SEQUENCE

(default [any] ORDER BY rdate = BOX)

WHEN not paid [cv()] = 1

THEN 1

WHEN offday [cv()] = 1

AND the SUM (unpaid) [d_num (cv-5) AND cv()] > = 3

THEN 1

0 OTHERWISE

END

, offday [any] = BOX

WHEN not paid [cv()] = 1

THEN 0

Of ANOTHER offday [cv()]

END

)

ORDER BY empid, rdate

;

I guess not paid is always 0 or 1.

Tags: Database

Similar Questions

  • Hi me Mamadou Moustapha I bought apple that i phone 6s a few days find out who the best phone of the world, because the day I bought it, I had questions on screen and when I went to the service center, they said they're going to update they have updated o

    Hi me yedess apple that i 6 s phone few days back knowing have the best phone in the world since the day I bought that I have questions on screen and when I went to the service centre they said they're going to update, I bought they updated after that I have the same problem now they say they're going to fix very terrible situation for apple this new product which has manufacturing defect they will repair, I asked to change device they deny because they want to fix m single i face the problem of the first day of the customer are powerless and that they only make just crazy.

    It's what warranties are for. If you bought the phone from Apple or an Apple authorized reseller, iPhone, you have 14 days to return it for a refund. After that the Bank should replace the phone. If you did not buy from Apple or a shop authorized, you must respect the terms of this store. However, Apple will always replace the phone, if you contact them directly.

  • Why my Apple ID several times to lock out "for security reasons" every day or 2?

    Why my Apple ID several times to lock out "for security reasons" every day or 2? This is getting very frustrating. I had to change my password 5 times in the last week. Anyone have any ideas?

    This means that someone is trying to access your Apple account.

  • I just bought a new laptop, the day of set-aside accidentally bump my classmate in my camera and it fell to the ground, got brocken screen, what will I do?

    I just bought a new laptop, mac pro 13 Inc. with retina book model no A1502, exactly on the day set-aside, it broke because my classmate accidentally jostled and he fell to the ground, the screen had a crack, I went to the store to ask for help, they just said to buy a new I felt so bad, what should I do?

    There should be a possibility outside replacement in the event of accidental damage warranty. Go to this store and ask them if there is any chance to get out of warranty repair.

  • Satellite L500-1XL: catering on the day of the purchase using HARD drive recovery

    Is this possible?

    I'm trying to restore my laptop to this day of purchase (only a month today). From what I see on the forum, I'm just in a long line of us discovered that the version of our recovery DVD does not match the product we bought. This is why I would like to restore the 64-bit version (without the option out of order price of recovery media that is shockingly overpriced compared the offer from Microsoft to switch to DVD 64-32 / 32-64 bit more shipping costs).

    () This brand of righteous 'aid' is subjective, condescending and above all and most relevant to this forum is useless. "I don't understand why you don't save up to 5,000 copies the day of purchase"... etc. We all make mistakes, and if you have done one, you're going to do on new. It's nice when the person we meet at this time is not pointing the finger of judgement)))

    > So, I would restore the 64-bit version (without the option out of order price of recovery media that is shockingly overpriced compared the offer from Microsoft to switch to DVD 64-32 / 32-64 bit more shipping costs).

    The laptop came pre-installed with Win 7 64 bit. In addition, you have the recovery disk Toshiba version of Win 7 32 bit.

    Please take a look in the user manual.
    He says that you can create a recovery in addition to the operating system which was pre-installed disk. means Win 7 64 bit.
    There should be a Toshiba Recovery Disk Creator called preinstalled tool. This tool allows to create own 64 bit Windows 7 new recovery disc.
    After you create this disk, you can use it to put the laptop in the same State as on the first day of purchase.

    Welcome them

  • How can I reset my R7000 in the State in which I out took it of the box?

    How can I reset my R7000 in the State in which I out took it of the box? Why am I asking? The latest version of the firmware has destroyed the connectivity and performance of my router. I'll have to deal with the devices that can not connect, devices that fall, extremely poor performance, etc. It's just a disaster.

    I've been with Netgear 5-6 years and had to do something last night, I have never had to do before - I had to go back to an earlier version of the firmware. Honestly, very little worked well. The previous version of the software has a few hiccups here and there, but the new version is just a nightmare.

    Now that I have applied even if an earlier version of the firmware, I can still see some of the latest options which were not there before. I have taken note that the firmware was now the prior publication, but the GUI is still the current version.

    Just to give a time frame on my Nexus 5 running 802.11ac, prior to the current version, I could peg 90Mbps +. Since the new version, the best I can do standing right next to the router is 24Mpbs +. Even after the restoration of the previous firmware, the speed is always the same.

    So, I want to return the router to the shape that when I took it out of the box, apply the previous firmware and reset up if necessary. I want to just my router back prior to the most recent release that destroyed. Once again, that the release had a few hiccups, but it was still usable.

    The 30-30-30 reset method works on most routers out there, but not on the R7000...
    The correct way to reset your R7000 at the exit of the State of the box is...

    Download the original version of Netgear R7000 Support HP http://downloadcenter.netgear.com/en/product/R7000(Firmware Version 1.0.0.96)

    Reset and flash back of any Stockfirmware on the original Stockfirmware:

    Power on the router
    Wait a few seconds
    Press Reset for 5-8 seconds max! **
    connect to 192.168.1.1
    Flash the original FW
    now that the router restarts
    Wait a few seconds
    Press Reset for 5-8 seconds max! **

    * After each reboot, the first login on StockFW screen should show something like "refresh the settings or the settings of loading.

    Now, it's as out of the Box.

    Reset and flash back to any DD - WRT FW to Stockfirmware initial:

    Power on the router
    Wait a few seconds
    Telnet to the router
    Run the commands:
    'clear the NVRAM '.
    'reboot '.
    Wait a few seconds
    connect to 192.168.1.1
    Flash the original Stockfirmware through the Administration tab (if the upgrade fails and the site is not available, try another browser such as Firefox, chrome, safari)
    now that the router restarts
    Wait a few seconds
    Press Reset for 5-8 seconds max! **

    * After each reboot, the first login on StockFW screen should show something like "refresh the settings or the settings of loading.

    Now, it's as out of the Box.

    I have reflashed several R7000 to initial Stockfirmware as the last FW with Beamforming was not stable enough after several days/weeks testing... The FW showed massive connection drops after 24 hours and only a reboot of the router fixed it (tested on 3 x R7000)

    The connection has dropped from 1300 to 66-256 after several hours...-. -.

    Now I'm waiting a new FW version with corrections of Wifi of Netgear.

  • updates that have failed the day 1, won't they update automatically the next day? and persevering until they are right? or what I need to do it manually? Dang! Tell me that it is not so...

    OK, so I'm at a dead end and had to buy a computer laptop refurb when my hard drive died while he's on leave.  Bought Monday, they had XP on it, but I checked the updates and it had 74 must be installed.

    I don't have access at home so I tried to install everything that was needed every day of the library since I bought this laptop on Monday.  On day 1, he said 74 needed to install updates, then I guess that the automatic far did a little more every day.  Finally the Service Pk 3 failed to install for the last 2 days.

    Now today I try again, but I'm looking back and see that some other updates in recent days have also failed.

    I don't want to go back and install each separately out of 110 undates installed.

    My question is: If one day some updates failed, the next day, wouldn't it automatically DL updates that failed the day before, get current?  If I were a computer, I would not keep DL and install new updates until the 'old' have been installed correctly.  So I just reasoning flawed or computers work this way?  Please tell me that I can't go back and redo all of those failed?

    Thanks a lot for your help in this matter!

    U

    .. .Meanwhile service pk 3 tells me he has finished loading and is ready to install, restart, etc... and I just canceled the installation because it seems that to me... If these other failures are not fixed first there will be the svc pk 3 effect, as well.  Of course they wish that no cat could have answered my question instantly... but no, he referred me to a technical person...

    Well, perfectionism causes procrastination... and sometimes it's just maddening... Please help me?

  • Leave a pc on all the time, as I always close the end of the day?

    I have recently been informed by a friend that computers should be left on at all times rather than close them at the end of the day,

    Apparantley shut down a computer translates the computer run slower?

    Please can someone tell me if this is correct?

    Thank you in advance with any help I can receive

    Your friend is, in my view, perpetuating an urban legend I've met regularly. I always shut my PC down when I'm done with her. Apart from anything else, this is the 'green' thing to do and your electricity bills will be reduced too.

    He move in your PC to parts that wear out because there is no such thing as a perpetual motion machine. These moving parts will fail more quickly if you leave the PC on 24/7. Leave the PC 24/7 means that it is necessary to clean more often if dust accumulates at a faster rate, which increases the risk of overheating.

    Please mark this as useful or response if applicable.

    Tricky

  • I have a model #1363 cnc:09 wireless mouse - 6802. IAM trying to find out if can replace the (transister)

    I have a model #1363 cnc:09 wireless mouse - 6802.    IAM trying to find out if can replace the part (transister) you insert into the usb connector.   mine was broken days after purchase.   This is my 3rd purchased this year.   the cost is going to add up, but I love the product if I can't get a new game that I'll have to try another brand

    Hello

    If you are talking about the Microsoft Mouse, please see the article mentioned below.

    How to replace Microsoft software or hardware, order service packs and replace manuals:
    http://support.Microsoft.com/kb/326246

    If it is a third-party material, contact the hardware vendor for replacement.

  • 2nd System Partition is not available and I don't have A Vista DVD or CD the day I bought my desktop computer.

    My system does not have a recovery partition which is accessible and I don't have the DVD to recover my system.  I bought my computer the day Vista came out and wanted the XP but the store would not give me an our sell me an XP cd or dvd.  I've was stuck with Vista and was not even given a DVD in case of system failure.

    Hello

    Normally, the recovery on a system partition is accessible by using a F key at the start of the initial system. For the corresponding key or combination of keys, see the documentation for your system or online from the manufacturer support.

    If you need a recovery media, you will need to contact the manufacturer for such. Do not use a retail disk as often, they do not contain the necessary drivers for the owner builder systems.

    Good luck, Rick Rogers, aka "Crazy" - Microsoft MVP http://mvp.support.microsoft.com Windows help - www.rickrogers.org

  • Windows Live Mail - starts OK on initialize to top every day but disappears later in the day.

    Running Windows Vista Home (Service Pack 2).  Using Windows Live Mail.

    Normal daily start up, once online I have no problem running Live Mail.  I check for emails, and once completed, I normally have to close the program.  Later in the day, when I want to check for other emails, even once is not a problem.

    However and on a random basis, there comes a time when I try to load Live Mail but it does not load.  Initially, the hourglass turns on and the light disc shows some activity, but Live Mail starts it.

    If I do a Ctrl + Alt + Delete to check what programs are running, it shows Live Mail.

    The only resolution I've found is to re - start the PC.  The model then rehearsals sometimes, but not always.

    Clues or fixes out there?

    The next time you check the status in the Task Manager, when you find Windows Live Mail click the switch button to see if that move you to the program and he opened for you.

    If it does not, in the Task Manager and then click Windows Live Mail and click on end task this is confirmed.  Once he is gone (give it some time), open another window, and then try to connect again.  It cannot solve the problem, but it's better than the re-start (if it works).

    I would like to know if one of these workarounds help solutions.

    If not, please transfer your question in Forum Windows Live Mail to: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.windows.live.mail.desktop where experts in this program will be happy to help you.

    Good luck!

    Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • get the name of the day of a date (format yyyy/mm/dd)

    Hello

    In blackberry java application development is possible to get the name of the day of a date (format yyyy/mm/dd).

    I have a date as 09/15/2013. I want the output like Sunday

    Thank you and best regards.

    Thank you reply Erwan fo...

    I post my code using... It can be used to get the name of the day for a date string.

    //SimpleDateFormat write = new SimpleDateFormat("EEEE-MMM-dd");//It will return Weekday name as full plus monthe name plus date
    SimpleDateFormat write = new SimpleDateFormat("EEEE");//It will return Weekday name
    Date date = new Date(HttpDateParser.parse("2013/09/12"));
    System.out.println(write.format(parsedDate));
    

    Best regards.

  • My computer hangs for 15-20 seconds many times throughout the day, suggestions to fix this?

    It seems no matter what I do on the computer, it will freeze for 10-15 seconds at a time, then run again the OK for a bit, then gel to the top.  This happens continuously throughout the day.  Any suggestions on what could happen?  I ran checks on the computer, but all system controls came out OK.

    It could be a sub-process or application that runs in the background
    and taking all the CPU resources.

    To find and view what could be the problem, try Process Explorer:
    http://TechNet.Microsoft.com/en-us/Sysinternals/bb896653.aspx
    SysInternals Forums: http://forum.sysinternals.com/

    Worth reading: the process system CPU spikes
    http://blogs.technet.com/markrussinovich/archive/2008/04/07/3031251.aspx

    Once you have Process Explorer installed and running:
    In the task bar, select view and check:
    'Show the process tree' and the options 'display the lower pane '.
    Move the cursor of your mouse over any column in the right pane and
    Make a right click and check the following boxes:
    "Command line" and "Version".
    Then expand the process named "Explorer" (click the plus sign +)
    In the left named "CPU" column, look for any high CPU usage.
    Then click on the CPU column to sort processes by CPU usage %
    (Highest to lowest).

    You can also hover and check any spike point or up/down in the chart of the CPU.

    Move the cursor of the mouse on any process,
    You should see a pop-up window with some detailed info.
    Then the mouse on the process using most or all the CPU %.
    Then click on this process to select,
    Now that it is highlighted, right click and select the options listed:
    "Online search".
    This should bring that out there on the web about this process.
    You can also double-click any process to open a more detailed
    "Properties" window

    Note: some entries such as explore, System/Services and Svchost
    To be expand to view details (sup process),
    in this case, click on the + to the left of the entrance.

    Another method when you use Process Explorer
    is to double click on the graph just below the menu bar.
    This will open the "System information" window, which has a larger screen
    of all the three graphs. Move your mouse over any Picot in the
    Graphic of the use of the CPU to see what process/application or service is the cause
    earworm.

    Another available tool is: RAMMap
    http://TechNet.Microsoft.com/en-us/Sysinternals/ff700229.aspx

    J W Stuart: http://www.pagestart.com

  • BlackBerry Smartphones FACEBOOK / SCHEDULE of the order of the DAY

    Can anyome tell me how to get the events of Facebook on my calkander of the order of the day? I have tried tweeking the settings in FB and its always there... Birthdays, etc... I have a large number of appointments and care when the class of 1988 birthdays is... Laughing out loud...
    BlackBerry Curve 8530
    Thank you...

    Hello huntmarv,

    Yes, it is possible to remove the entries from Facebook - you need the BlackBerry Desktop Software to do this (available at www.blackberry.com/software/desktop)

    First of all make sure that you back up your calendar - there will be a stage where the database will be cleared out.

    Here's what you can do:

    1. In Facebook, go to Menu > Options and make sure that the control is removed from Connect to the BlackBerry calendar
    2. Connect your BlackBerry to the desktop software
    3. Back up your data
    4. On your BlackBerry, go to Options > Advanced Options > default Service
    5. Change the calendar by default of this current selection to Facebook (remember the current default value to change it back later)
    6. Desktop software go to device > delete data and change the blue button on selected data
    7. Scroll down until you see calendar - there is also a calendar - everything, but you do not want this option. You should see that the figures for these are different. Calendar is the current calendar, which in this case is now on Facebook.
    8. If you want to save these data once more, just in case, you have the possibility to save before deleting the date.
    9. When the removal has completed, disconnect your BlackBerry.
    10. Consult your calendar - Facebook entries should now removed
    11. In your Options > Advanced Options > Services by default, change the default calendar to the default initial value

    I know that sounds like a long process, but you should be able to do quickly, as long as you follow the steps. If you have any questions, let me know.

    Good luck!

  • my internet connection has been cut, and then I tried to find out. I opened the Troubleshoot, it says that I need to install a driver for my network card. I use Windows 7 Ultimate.

    Two days ago my internet connection has been cut, and then I tried to find out. I opened the Troubleshoot, it says that I need to install a driver for my network card. I use Windows 7 Ultimate. What should I do? Should I re install windows 7 ultimate on my computer?

    Hello

    What brand / model of the computer?

    There is no need to re - install Windows 7. You just need to install the network card drivers. Check out the link and follow the steps.
     
     

Maybe you are looking for

  • How can I remove "bucksbee loyalty program?

    Cabre loyalty bee program - UNINSTALL How can I remove this from Firefox? Nothing WON'T find in anti-virus applications or malware.

  • Lack of a modem 3G in Portege R400

    Dear experts! Model: Portege R400 (PPR40E-00T019RU)OS: Vista Ultimate 32 bit1. under the keyboard is the slot for SIM card,.2. on the front panel, a LED and Toshiba edge the pictogram of a cellular network that suggests presence 3 G modem in my copy

  • Measure the voltage and the temperature simultaneously with PCI-6281

    Measure the voltage and the temperature at the same time at the same time. However, when I put the voltage and temperature in a loop, the acquisition of voltage is significantly delayed. When I put the voltage and temperature in two different loop, n

  • I have windows 7 Professional

    I don't have microsoft Freecell card games, hearts or solitaire can download these from microsoft and how

  • Update SmarThru4 problems

    Help!I recently acquired an automatic update that makes my life impossible. When I go to copy and paste something to a web page as a blog, etc. the "Paste" option is grayed out and I can't paste in it. I deleted the program SmarThru4, but nothing has