![](/img/trans.png)
[英]Difference between data of two different row belonging to two different columns in SQL
[英]Sql : Difference between two columns for each row
PDO# Item Code To Issue InStock i want to see
63551 724S3607-109M02_01 1 60 59
63552 724S3607-109M02_01 1 60 58
63553 724S3607-109M02_01 2 60 56
63554 724S3607-109M02_01 7 60 49
我要查看的列中的数据是 60-1(有货到发行),59-1(我想看 - 发行),58-2(我想看 - 发行),56 -7(我想看看 - 发出)等等。 任何帮助表示赞赏。
您可以使用如下查询
Select *, YourOutputColumn = InStock - Sum([To Issue]) over(partition by [Item Code] order by [PDO#])
from yourtable
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.