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

sql sum 条件求和

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(xsl)as yxsl, id , to_char(date,'yyyymm') as month from 表名 where year=$year group by id,to_char(date,'yyyymm') 按id和月份分组

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

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

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

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

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

因为你的*号,使用了聚合函数,那么前面出现的字段后面必须要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和月份分组

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