如何在SQL Server的特定列中添加所有数字 [英] How to add all the numbers in a particular columns in sql sever

查看:121
本文介绍了如何在SQL Server的特定列中添加所有数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,程序员,

在这里遇到了问题.如您所见,我操纵表中的所有数据.但是首先这是我的字段名称;名称,类别,数量,大小.现在,当我操作数据库时,说:

Hello programmers,

Got a problem here. As you can see I manipulate all the data in a tables. but first here are my field names; name, category, amount, size. Now when I manipulate the database, say:

NAME CATEGORY AMOUNT SIZE
         man  banana    12    7          and
         girl  ball     30    2


那将是数据库中的外观.
我的问题是,我可以将所有数字加起来吗?所有数量的数字都将相加.

感谢和更多的力量


That will be the look in the database.
My question is that, can I add all the numbers say on amount; all the numbers in amount will be added.

thanks and more power

推荐答案

使用非常简单的SQL代码可以做到这一点:

从TABLENAME中选择sum(Amount)作为TotalAmount
Very simple SQL code to do this:

select sum(Amount) as TotalAmount from TABLENAME


这篇关于如何在SQL Server的特定列中添加所有数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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