tnfh.net
当前位置:首页 >> sql 里sum 条件求和 >>

sql 里sum 条件求和

select sum( 使命感+团队意识+工作能力+学习力+组织原则 ) where name='白浩' and 评价人='lichunlong'

select sum(case when mark = 0 then point else 0 end) as Point_0, sum(case when mark = 1 then point else 0 end) as Point_1, Account from 表A group by Account; *************** 我从不辩解,测试log自己看: [TEST@ORA1] SQL>select * ...

select 单位性质,sum(在职),sum(离职)from 表group by 单位性质是要这样?

select sum(xsl)as yxsl, id , to_char(date,'yyyymm') as month from 表名 where year=$year group by id,to_char(date,'yyyymm') 按id和月份分组

select sum(id4),count(*) from a_temp ; 可以一句SQL就直接查询得到列的和以及记录数。 该SQL中sum(id4)是列id4的总和, count(*)是得到的数据总行数。

转换为decimal类型,小数位数自己设定 比如:cast(sum(cast(字段) as decimal(18,2)) as decimal(20,2))

select sum(case when mark = 0 then point else 0 end) as Point_0, sum(case when mark = 1 then point else 0 end) as Point_1, Account from 表A group by Account;

select 外服名称,缴费月份,sum(社保基数) as 社保基数之和from 表1group by 外服名称,缴费月份

可以通过sum进行求和,通过where语句进行条件判断。 sql:select count(socre) from tablename where name like '张%' and id>5; 解释:以上就是通过条件查询出名字以张开始的,id大于5的所有人的socre。

假如你的数据列名为:a,b,c,d,e,f,g 那么你横向汇总的SQL语句是: select a,b,c,d,e,f,g,a+b+c+d+e+f+g from 表名 那么你纵向汇总的SQL语句是: select sum(a),sum(b),sum(c),sum(d),sum(e),sum(f),sum(g) from 表名 求所有数据总和的SQL语句是:...

网站首页 | 网站地图
All rights reserved Powered by www.tnfh.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com