Wouldn’t the median be equal to adding the 2 values together first and then divide the result by 2 (i.e. (Bottom + Top) / 2 )?

Thanks for the code. I had used Jonathan’s but yours takes out the guesswork..

]]>`declare @totalusecounts int`

```
```select @totalusecounts = sum(usecounts) from #statementcosts

`;with Weighted AS`

(

select (StatementSubTreeCost * usecounts)/@totalusecounts [Wgt]

from #statementcosts

)

select sum(Wgt) [WeightedAverage] from Weighted

Which set of values I need to consider for calculation 1) below 100 or above 100 .

If I exclude them .. then the figures are like below

Median 848.68

Mode 347.26

Average 1713.596471 ]]>

980.126153

MEDIAN

259.730000

MODE

8.73

Could you please suggest me how to decide cost of threshold based on above figures?

]]>