Ⅰ sql SEVER分类汇总后求和
select sum(出口量) from (
select top 5 * from (
select 国家,sum(出口量) 出口量 from table group by 国家) aa order by 出口量 desc
)k
Ⅱ sql分组求和
select sum(case d when '1' then a when '2' then b else 0 end ) from 表 group by c
Ⅲ sql分组求和语句
1.如果2张表的字段一致,并且希望插入全部数据,可以用这种方法:
INSERT INTO 目标表 SELECT * FROM 来源表;
insert into tablemubiao select * from tableinsert;
2.如果只希望导入指定字段,可以用这种方法:
INSERT INTO 目标表 (字段1, 字段2, ...) SELECT 字段1, 字段2, ... FROM 来源表;
注意字段的顺序必须一致。
insert into tablemubiao(id) select id from tableinsert;
Ⅳ 怎么用sql语句来实现分组求和
第二列第一行是不是写错了? 应该是5 ?
select 名称,min(金额) 类型1,max(金额) 类型2,sum(金额) 金额合计 from 表名
group by 名称 order by 1
Ⅳ SQL分组求和
selectnvl(job,'总计:'),
count(1)员工数量,
count(distinctdeptno)部门数量
from(selectdeptno,nvl(job,'')jobfromemp)a
groupbyrollup(job)
orderbyjob
以上是oracle语法,你试下。
Ⅵ 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
Ⅶ sql 分类求和
分类求和需要用sun函数。
1、如emp表中数据如下:
Ⅷ sql 如何对指定的分组进行求和
子查询 sum 求和 avg 平均
Ⅸ 怎么把两列的数据求和(先每列求和,再把结果再相加)sql数据库
1、在数据中打开一个存在整数数值的表,然后可以看到右下角就有查看的表格数据。
Ⅹ sql 按类型分组求和
参考sql语句
select no ,
max(case when type=1 then type) else null end) type1,
max(case when type=2 then type) else null end) type2,
sum(case when type=1 then sumsource) else null end) source1,
sum(case when type=2then sumsource) else null end) source2,
from(
selct no , type, sum(source) sumsource
group by no,type
)