开发者

Evaluating formula in SQL

I am trying to process salary details of employees depends upon some schedule using SQL Server 2005. Here some fields are evaluating from formula. like..eg.

HRA=(BS+Earning1)*10/100

here formula is getting from Table, it'll vary for diff accounts(HRA, Medical Allavance etc). Value of formula operators (eg. BS, Earning1) are in table. I want to replace operator string开发者_如何转开发s with its value and to get formula result. Thanks in advance.


Depends on the table and data. This should help.

SELECT account, (BS+Earning1)*10/100 as [SaleryFormula] 
FROM Table

BS will be replaced with the value in BS column for that account. That assumes each account has a single record in the Table. Otherwise

SELECT account, (SUM(BS)+SUM(Earning1))*10/100 as [SaleryFormula] 
FROM Table 
GROUP BY account
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜