Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

A query with workingdays per month per persons per period

user10870042Feb 13 2010 — edited Mar 4 2010
Can anyone help me on the way in building a difficult SQL query?

I work with Oracle SQL. It is intended to calculate over a certain period, to find the working days for each month for each person.

I have a working query for calculate the number of days for 1 months minus holidays

Select count (*) NUM_WORK_DAYS
From (
Select to_date ('01-01-2010 ',' dd-mm-yyyy ') + ROWNUM-1 as day
From all_objects
Where ROWNUM <to_number (to_char (last_day ('01-01-2010 '), DD')) + 1)
Where to_number (to_char (day, 'd')) between 1 and 5
And not exists (select NULL
From HOLIDAY
Where Holiday.hol=day)

There is a datetable with the following structure where I can get the periods:
DATES
YEAR | MONTH | WEEK | SD
2010 | 201002 | 201006 | 09/02/2010
All required months are present
It is intended that the user give a beginning and a end time specify.

I have a table of workingdays per person named
CALENDAR
CAL | MON | TUE | WED | THU | FRI | SAT | SUN
Person | Y | Y | N | Y | Y | N | N

And a table of holidays
HOLIDAY
CAL | HOL
Person | 01/01/2010

How can I combine the query for working days and build a query that returns for multiple people over multiple months the number of workingdays per month? I will ask the user to give a beginning period and a end period

I am aware that I ask a lot of your time, but I can not imagine the solution myself. Many thanks in advance

Gr,
Els
This post has been answered by 730428 on Feb 15 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2010
Added on Feb 13 2010
5 comments
2,474 views