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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 new help I want a write a inline table function

Author  Topic 

sarahmfr
Posting Yak Master

214 Posts

Posted - 2012-05-30 : 15:59:31
I want to perform the following operation
I copied the excel spread sheet that has the calculation required for the function
assessmentid GradeStatus maxpoint score rownumber assessmentcategory CatWeight deletelowest
12549 G 100 100 1 301 15 0
15337 G 100 60 1 302 5 0
15336 G 100 65 2 302 5 0
12548 G 100 85 3 302 5 0 0
15347 G 10 9 4 302 5 0
15339 G 10 10 5 302 5 0
15340 G 10 10 6 302 5 0
15341 G 10 10 7 302 5 0
15342 G 10 10 8 302 5 0
15343 G 10 10 9 302 5 0
15344 G 10 10 10 302 5 0
15345 G 10 10 11 302 5 0
15346 G 10 10 12 302 5 0
12543 G 100 66 1 303 40 1
12542 G 100 70 2 303 40 1
12544 G 100 90 3 303 40 1
2389 G 100 74 1 304 40 1
2360 G 100 85 2 304 40 1

steps
categoryid catweight TotalScore TotalMaxPoints perc perc =(catweight*totalscore*1.0)/ TotalMaxPoints
301 5 299 390 3.833333333 else TotalMaxPoints
302 15 100 100 15 end)
304 40 85 100 34
303 40 160 200 32
100 84.83333333
final percentage= 84.83333333 final percentage= (SUM( perc)*100.0)/SUM(catweight)

we need to divide by total catweight because may be one of the categories has all null numbers so it will not be included
we are excluding null scores and delete lowest ones.


sarah

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-30 : 16:12:44
see guidelines on how to post proper data for question

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -