如何在sql中编写下面这个excel公式,请参见下面的示例问题 [英] How to write this excel formulae below in sql see problem below with example

查看:83
本文介绍了如何在sql中编写下面这个excel公式,请参见下面的示例问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

A        B     C           D            E
ItemID  weight Service     Eventdate   weightgain or lost(Col B)
16568906    24  Programme   05/10/2015  
16568906    24  Trainer     05/10/2015      0
16568906    29  Programme   28/01/2016      5
16568906    29  Trainer     28/01/2016      0
168906      23  Trainer     29/01/2016  
168906      20  Trainer     30/01/2016     -3
1656890610  28  Programme   05/10/2015  
1656890610  35  Programme   06/10/2015      7
1656890610  30  Programme   07/10/2015     -5







= IF(A1 = A2,B2-B1)给出结果在col E



我尝试过:



我正在尝试在Sql中复制excel公式,我尝试使用累积值但从不工作




=IF(A1=A2,B2-B1) give result in col E

What I have tried:

I'm trying to replicate an excel formulae in Sql and I have try to use cumulative value but never work

推荐答案

全部您正在寻找的是累积总和运行总计运行总额



从这里开始:计算SQL Server中的简单运行总计 [ ^ ]
All what you're looking for is called cumulative sum or running totals or running sum.

Start here: Calculating simple running totals in SQL Server[^]


这篇关于如何在sql中编写下面这个excel公式,请参见下面的示例问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆