i am working on a Gridview on ASP .Net. I have a table in SQL Server which has columns named “surname” and “Date” (DateTime) and duration. The table is for vacation requests. How can I construct a SQL statement to see how many people will be missing for each day?. The point is that the query SELECT [Date], COUNT(DISTINCT surname) GROUP BY [Date] will not show me that actually 8 people will be missing at 2 of september. For example, given the following data:
surname Date Duration
------- ---------- ---------
Bertram 2011-09-01 3
Coulois 2011-09-01 5
LeBlanc 2011-09-01 6
Fosters 2011-09-01 3
Blanche 2011-09-01 2
Bertram 2011-09-02 6
Gillian 2011-09-02 4
Pikklar 2011-09-02 7
Thierry 2011-09-03 6
Selanne 2011-09-03 6
I want the following results:
Date Count
----- -----
1 Sep 5
2 Sep 8
3 Sep 10
Any ideas how to approach it and produce a gridview with those data?. Thx for your time
The following should give you a breakdown of all holiday starting with the first day booked and ending with the last day booked off (not just the start date). It should also report dates within the range with zero bookings (if any exist);
The code works out the last booked date and then calculates all bookings for each day in the dynamic date range
hope this helps…