永发信息网

SQL SEVER求和算同比

答案:3  悬赏:40  手机版
解决时间 2021-11-09 08:59
  • 提问者网友:饥饿走向夜
  • 2021-11-08 17:39
SQL SEVER求和算同比
最佳答案
  • 五星知识达人网友:骨子里都是戏
  • 2021-11-08 18:54
select 月份,(SUM(case when 年份=2015 then 出口量 else 0 end)-SUM(case when 年份=2014 then 出口量 else 0 end))*100.0/SUM(case when 年份=2014 then 出口量 else 0 end) 增长率百分比
    from [hgsj].[dbo].[seamless]
       where 年份 in(2014,2015)
          group by 月份追问你写的语句格式非常好。我是想算(2015年1-9月和值-2014年1-9月和值)/2014年1-9月和值),结果就是一个数。追答select (SUM(case when 年份=2015 then 出口量 else 0 end)-SUM(case when 年份=2014 then 出口量 else 0 end))*100.0/SUM(case when 年份=2014 then 出口量 else 0 end) 增长率百分比
from [hgsj].[dbo].[seamless]
where 年份 in(2014,2015) AND 月份 between '01' and '09'
全部回答
  • 1楼网友:廢物販賣機
  • 2021-11-08 20:01
1. 你的 create table xxx .. 语句
2. 你的 insert into xxx ... 语句
3. 结果是什么样,(并给以简单的算法描述)
4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
  • 2楼网友:撞了怀
  • 2021-11-08 19:04
1. 你的 create table xxx .. 语句
2. 你的 insert into xxx ... 语句
3. 结果是什么样,(并给以简单的算法描述)
4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯