如何获得表中的总薪水 [英] How to get Total salary in Table

查看:68
本文介绍了如何获得表中的总薪水的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个表Sal.there只有两列。

创建表sal(emp varhar(50),薪水nvarchar(100))

在薪资领域有这么多的价值。如何获得工资总额列。

喜欢

sal

$

20,000

30,000

如何获得sal值的总和。

解决方案

首先,改变数据类型 [ ^ ] Salary 列接受数值而不是字符串。使用 ALTER TABLE [ ^ ] comand:

  ALTER   SAL  ALTER   COLUMN 薪水 DECIMAL  10  2 



其次,使用如下查询:

  SELECT  SUM(薪水)
FROM SAL;


 选择 SUM( CONVERT ,薪水)) AS 总计来自 sal 


您好benzimen,



选择总和(施放(替换(工资,',','')作为浮动))来自sal;



希望这对你有帮助..


There is One Table Sal.there is only two columns.
create table sal(emp varhar(50), salary nvarchar(100))
In Salary Field there is so many values.How can i get Total amount of Salary column.
like
sal
10,000
20,000
30,000
how to get sum of sal values.

解决方案

First of all, change the data type[^] for Salary column to accept numeric values instead of string. Use ALTER TABLE[^] comand:

ALTER TABLE SAL ALTER COLUMN Salary DECIMAL(10,2)


Secondly, use query like this:

SELECT SUM(Salary)
FROM SAL;


select SUM(CONVERT(money, salary)) AS Total from sal


Hi benzimen,

select sum(cast(replace(salary,',','')as float)) from sal;

Hope this will helpful for you..


这篇关于如何获得表中的总薪水的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆