数据库分类求和 数据库求和语句
分类求和需要用sun函数.1、如emp表中数据如下:2、现要按照deptno字段分组,求每个分组下的sal的和,可用如下语句:select deptno,sum(sal) from emp group by deptno;3、执行结果:
sql分组求和select sum(case d when '1' then (case e when 1 then aa when 2 then bb end ) when '2' then b else 0 end ) from 表 group by c 当然可以,你少了个then
数据库分组求和的写法?select distinct b,sum(case c when 1 then c else 0) c,sum(case d when 1 then d else 0) d,sum(case e when 1 then e else 0) e,sum(case f when 1 then f else 0) f, distinct g from ddd order by b
sql 分类求和?声明三个字段都是varchar 类型的正确语句是:select dm,xm,sum(sl) from t group by dm,xm
sql按列分组求和SELECT CONVERT(varchar(7),日期,120),货号,sum(数量) as 数量,sum(金额) as 金额 from table group by 日期, 货号
sql分组求和查询语句select a字段,b字段,c字段,sum(d*e) as 新列,sum(f字段) as f字段,sum(g字段) as g字段 from 表 where h字段>='2015-03-01' and h字段
sql 分类求和?就是分组求和,用group by和sum()就可以了select 列名1,列名2,sum(列名3) from 表名group by 列名1,列名2
求一个sql表的分类求和语句select name,code,sum(number) from Table group by name,code
sql分组求和select sum(case d when '1' then a when '2' then b else 0 end ) from 表 group by c
分类汇总SQL求和语句!分类汇总很简单select 名称,sum(数量) as '数量'from tablegroup by 名称然后再求大20的数量=70 这个没看懂