Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
SQL
declare @d1 datetime,
	 @d2 datetime , @friday int
select @d1 = '2012-11-01',@d2= '2012-11-18' ;
with dates ( date )
as
(
select @d1
union all
select dateadd(d,1,date)
from dates
where date < @d2) select @friday= COUNT(date) from dates
  where datename(dw,date) = 'Friday'
 select  COUNT(*) as HolyDay  from HolyDaySetup where FromDate between '2012-11-01' and '2012-11-18'
 Declare @holiday int ,@monthDay int
 select @holiday= COUNT(*)  from HolyDaySetup where FromDate between '2012-11-01' and '2012-11-18'
select @monthDay= DATEDIFF(day,@d1,@d2)+1 
Select @monthDay -( @holiday + @friday) As WorkingDay

Here it returns only WorkingDay. But I want all column to show together.
Suppose
SQL
SELECT Friday, HoliDay , Month, and WorkingDay ..... Where between '2012-11-01' and '2012-11-18'.

I can't solve this problem. Please help me.
Posted
v2
Comments
Bhushan Shah1988 22-Nov-12 4:44am    
provide your full code.
Maksud Saifullah Pulak 22-Nov-12 6:35am    
Can you please send you full code?
Neil70 29-Nov-12 7:36am    
Can you give us the Structure of table HolyDaySetup and a few rows of data for it?
Can you also clarify the output structure you are expecting? Thanks.
Aarti Meswania 12-Feb-13 23:49pm    
Please elaborate question what's your table and what o/p you want

1 solution

what you want is to pivot your rows into columns. sql 2008 has a command for that. check : http://msdn.microsoft.com/en-us/library/ms177410(v=sql.105).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900