Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6473099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:25:32+00:00 2026-05-25T06:25:32+00:00

i am working on a Gridview on ASP .Net. I have a table in

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:25:32+00:00Added an answer on May 25, 2026 at 6:25 am

    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);

    2011-09-01  5
    2011-09-02  8
    2011-09-03  10
    2011-09-04  9
    2011-09-05  7
    2011-09-06  7
    2011-09-07  5
    2011-09-08  4
    2011-09-09  3
    

    The code works out the last booked date and then calculates all bookings for each day in the dynamic date range

    DECLARE @MaxDate date
    SELECT  @MaxDate = max(dateAdd(day, duration, date)) 
    FROM holiday;
    
    WITH HolidayDates (holidayDate)
    as
    (
        SELECT  MIN(date) holidayDate 
        FROM    holiday 
        UNION ALL 
        SELECT  DateAdd(day, 1, holidayDate)
        FROM    holidayDates 
        WHERE   holidayDate <@MaxDate
    )
    
    SELECT      cast(hd.holidayDate as date) holidayDate
                , count(h.surname) PeopleOnHoliday
    FROM        HolidayDates hd
    LEFT JOIN   holiday h on hd.holidayDate between h.date AND dateAdd(day, duration, date) 
    GROUP BY    hd.holidayDate
    ORDER BY    hd.holidayDate
    

    hope this helps…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a gridview i am working on VS2008 ASP.Net forms Currently, my update
I am working with asp.net 2.0 project. I have a gridview in one of
I am working on an ASP.Net website and have a GridView displaying some data,in
I am using asp.net and I'm working with a gridview. I have one of
I am working on Gridview in ASP.NET(C#) and have cells that need to have
i have a asp.net webpage with a GridView <asp:GridView ID=grid_view runat=server AllowPaging=True AutoGenerateColumns=False BackColor=White
I currently have an ASP.NET GridView that displays a few columns to the user
I am working on an application that has a GridView item on an ASP.net
I have an ASP.NET GridView which displays a list of neighborhoods. I wish a
I am working on a GridView in Asp.Net. When initially a the Page Loads,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.