www.3112.net > sql语句金额相加

sql语句金额相加

用sum加不就行了?如下declare @t table (a money,b money,c money)insert into @tSELECT 100,300,420 union allSELECT 43,35,33 union allSELECT 80,2,1SELECT sum(a) as a,sum(b) as b,sum(c) as c,sum(a+b+c) as total from @t

select sum(字段名) 相加之和 from 表名 where 条件

update [revenue] SET revenue_money=revenue_money+3.55 where revenue_date=#2008-4-8#

你上面的SQL语句不就是么只要把金额去掉就可以了啊select SUM(金额),名称,金额, aa from test1 改成select SUM(金额),名称,aa from test1

将两个值分别付给两个变量.将第一个count(*)改为count(1),第二个改为count(2),count(1)+count(2)即可

select name,sum(kd金额) from TABLENAME group by name;

select sum(欲求值列明)as 求和后希望的名称from 表的名称where 时间列>='时间' and 时间列 <='时间'[group by 需要分类统计]注意,group by 不要加多了,因为group by 是要按照这列分组之后求和.

将数字转为字符串,在相加,SQL提供了相关函数;UPDATE T_TABLE SET C= (A + STR(B) ) -- T_TABLE 表名

在表中再加一列 例如state 列.将这三列的state的值设为1.其他的为0.1就代表需要进货的那三个产品. 用select * from 表 where 单号=1001 and state=1 即可

用if判断呀,入库就用总和+money,出库就用总和-money

网站地图

All rights reserved Powered by www.3112.net

copyright ©right 2010-2021。
www.3112.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com