Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
muzaffar_ali99
Starting Member
33 Posts |
Posted - 2007-04-26 : 04:42:32
|
I have a table in earned points,total points and Date is residing, The problem is i want to calculate percentage but displaying data in months for exampleTbl_ScoreScoreId Earned_Points Total_Points Points_Date1 2 5 04/26/20072 3 10 05/05/2007 3 10 10 06/07/2007Now My Desired result is Score Jan Feb Mar April May June July Aug Sep Oct Nov Dec40% 0% 0% 0% 40% 3% 100% 0% 0% 0% 0% 0% 0%Means i want to show a trending report on the basis of score in Months Columns and also on give year mean data of 2006 or 2007 etcRegardsMuzaffar Ali |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-26 : 04:45:24
|
select datepart(year, points_date),sum(case when datepart(month, points_date) = 1 then 1 ELSE 0 end) as 'January',sum(case when datepart(month, points_date) = 2 then 1 ELSE 0 end) as 'February',...from tbl_scoregroup by datepart(year, points_date)order by datepart(year, points_date)Peter LarssonHelsingborg, Sweden |
 |
|
muzaffar_ali99
Starting Member
33 Posts |
Posted - 2007-04-26 : 05:28:12
|
Thanks that works great. |
 |
|
|
|
|