如何根据百分比计算查询结果

时间:2015-09-21 07:37:27

标签: sql stored-procedures

我想在百分比的基础上计算查询结果,这是从网站的管理面板设置的。 有四种状态相同。 金,银,铜和麦德林。 我目前的公式是

select * , isnull( CASE WHEN RowNumber <=  (@totaltopPromoters*@Gold/100) Then 1
                       WHEN RowNumber >= (@totaltopPromoters*@Gold/100) and RowNumber <= (@totaltopPromoters*@Gold/100) + (@totaltopPromoters*@Silver/100) THEN 2 
                       WHEN RowNumber>=(@totaltopPromoters*@Silver/100) and RowNumber<= (@totaltopPromoters*@Gold/100)+(@totaltopPromoters*@Silver/100)  + (@totaltopPromoters*@Bronze/100)THEN 3 
                       WHEN RowNumber>=(@totaltopPromoters*@Medallion/100) and RowNumber <= (@totaltopPromoters*@Gold/100)+(@totaltopPromoters*@Silver/100)  + (@totaltopPromoters*@Bronze/100)+(@totaltopPromoters*@Medallion/100) THEN 4
                       end ,0) as  
                    TrophyType

有人可以指导我吗?

0 个答案:

没有答案