February 13, 2014 at 3:28 pm
I am trying to count all devices and arrange them on a weekly basis. so
So the output should be the counts in the following order 2014-07,2014-06,2014-05 .....2014-01 ,2013-52,2013-51
Table has WeekNumber column as Int, Month Number as Int and Year Number as int.
My Query shows the output as 2013-01,2013-02....2013-52 , 2014-01 ,2014-02....2014-07
With CTE1 as
(Select Count(*) CountDevices,Year_Number,Month_Number,Week_Number
From Prod
Group By Year_Number ,Month_Number,Week_Number
)
Select CountDevices,Cast(Year_Number as Varchar(10)) + '-'+ Cast(Week_Number as Varchar(10)) from CTE1
Order By Cast(Year_Number as Varchar(10)) ,Cast(Week_Number as Varchar(10))
Any Ideas to get the desired output
February 13, 2014 at 4:07 pm
You could post DDL, sample data and expected results to get better answers. I'm sure you've been told how to do that.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply