you need to use a calendar table for that.logic will be like belowSELECT c.CalendarDate,CASE WHEN t.DateColumn IS NULL THEN 'A' ELSE 'P' ENDFROM CalendarTable cLEFT JOIN YourTable tON t.DateColumn = c.CalendarDateWHERE c.CalendarDate > = @StartDateAND c.CalendarDate < @EndDate + 1AND DATEDIFF(dd,0,c.CalendarDate)%7 <=4
you need to declare @StartDate and @EndDate as parametersif you dont already have a calendartable use this insteadSELECT c.CalendarDate,CASE WHEN t.DateColumn IS NULL THEN 'A' ELSE 'P' ENDFROM dbo.CalendarTable(@StartDate,@EndDate,1,0) cLEFT JOIN YourTable tON t.DateColumn = c.[Date]
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs