fyqt.net
当前位置:首页 >> sql sum group By >>

sql sum group By

select 物品主键,物品编码,物品名称,sum(库存数量) as s1,sum(出库数量) as s2 from 物品表 group by 物品主键,物品编码,物品名称

这个样子?sqlserver? update a set a.hour=c.hour from a inner join (select id,sum(isnull(hour,0)) hour from b group by id) c on a.id=c.id

你是要按月分和销售人员来对销售额透视,而sql语句只对月份分组,正确结果应该增加分组维度 select月份,sum (case when 销售人员='姓名1' then 销售数量*产品单价 else 0 end) as 姓名1销售额,sum (case when 销售人员='姓名2' then 销售数量*产...

select a.name,sum(b.count) from a join b on a.type=b.type group by a.name

select c1 sum(c2) from t1 group by c1 order by 2 没有问题请采纳哈 首先你ORDER BY 后面的列名要在SELECT后存在,SUM后的列要给一个别名然后ORDER BY 这个别名,要么就用它的顺序号,如你这个语句里 ding.ord_amt是SUM里的字段名没有给别名所...

select top 10 商品编号 = b.goodsId,商品名称 = b.goodsName,销售数量 = sum(c.quantity) from GoodsType a join GoodsInfo b on a.typeId = b.typeId join OrderGoodsInfo c on b.goodsId = c.goodsId where a.typeName = '野营用品'group by ...

left join select要快。group by的字段越多耗费越高

这里统计出来的销售量肯定是有问题的。在表A left join 表 B on a.编号=b.编号的情况下,当编号相同的记录在a表中有多条通话记录的时候,销售量也就扩大到多少倍.例如:编号为1的,在a表中有5条通话记录,在b表中有一条记录,销售量为4.然后a表和b表一...

可以的,group by后边整个条件 就是列: CASE country WHEN'中国' THEN'亚洲' WHEN'印度' THEN'亚洲' WHEN'日本' THEN'亚洲' WHEN'美国' THEN'北美洲' WHEN'加拿大' THEN'北美洲' WHEN'墨西哥' THEN'北美洲' ELSE'其他'END

select company_id,budget_id,sum(full_money),sum(check_money) from tmsdz.r_main group by company_id,budget_id

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