Re: Populate table with stored proc



In addition, if you meant to have the data into the schedule table by
listing the ranges of dates between the days off for each employee, you can
get the data like this (ROW_NUMBER assumes SQL Server 2005 is used):

SELECT emp_id,
MIN(date) AS StartDate,
MAX(date) AS EndDate
FROM (
SELECT E.emp_id,
C.date,
C.date - ROW_NUMBER() OVER(PARTITION BY E.emp_id
ORDER BY C.date) AS RangeGroup
FROM DaysOff AS E, CalendarDays AS C
WHERE C.date BETWEEN @start and @end
AND NOT EXISTS
(SELECT *
FROM EmployeeDaysOff AS O
WHERE O.emp_id = E.emp_id
AND O.dayoff = C.calendar_dow)) AS S
GROUP BY emp_id, RangeGroup;

Plamen Ratchev
http://www.SQLStudio.com


.



Relevant Pages

  • Re: Creating listbox
    ... named range each time an employee is added. ... What I mean is that I create name ranges today ... for each employee that belongs to eg department AAA. ... I think that you will need to create new independent lists of each ...
    (microsoft.public.excel.programming)
  • Re: Creating listbox
    ... to gmail if mailing direct) ... I think that you will need to create new independent lists of each ... Update defined name ranges automatically upon adding new employees. ... Employee 1 Department AAA ...
    (microsoft.public.excel.programming)
  • Re: Creating listbox
    ... for each employee that belongs to eg department AAA. ... I think that you will need to create new independent lists of each ... Update defined name ranges automatically upon adding new employees. ... Employee 1 Department AAA ...
    (microsoft.public.excel.programming)
  • Re: CountIf Function Help Needed
    ... do one per team, then total all the subtotal formula in a regular sum, the above formula ... Column C Contains Number of hours worked - my be null value if employee did not work. ... multiple ranges: ie. A3:A22, A40:A75 because the employees are broken up ... Then again, if the countIf function ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Calculating totals depending on cell value
    ... If you add a new employee, then you will have to add another formula. ... > like a way to figure out the totals when the sheet is open or becomes ... You can expand the ranges to allow for ... >> Jim Cone ...
    (microsoft.public.excel.programming)